473,626 Members | 3,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exporting to Excel directly from ObjectDataSourc e?

ASF
Hey all,
I have a gridview with an objectdatasourc e. I've been using the below
code to export to excel:

gvITV.AllowSort ing = False
gvITV.DataBind( )
Dim tw As New IO.StringWriter ()
Dim hw As New System.Web.UI.H tmlTextWriter(t w)
Dim frm As HtmlForm = New HtmlForm()
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.AddHea der("content-disposition",
"attachment;fil ename=export.xl s")
Response.Charse t = ""
EnableViewState = False
Controls.Add(fr m)
frm.Controls.Ad d(gvITV)
frm.RenderContr ol(hw)
Response.Write( tw.ToString())
Response.End()
gvITV.AllowSort ing = True
gvITV.DataBind( )

However, I dislike that I have to pull from the Gridview at all. I
should be able to skip the gridview binding and pull directly from the
objectdatasourc e, but I haven't been able to discover a way to do
this. Does anyone have any suggestions?
Jun 27 '08 #1
2 4216
I've documented a number of ways to export data to Excel:
http://SteveOrr.net/articles/ExcelExport.aspx
http://SteveOrr.net/articles/ExportPanel.aspx

If your needs turn out to be more advanced, you might want to invest in a
good 3rd party component such as one of these:
http://SteveOrr.net/reviews/AsposeExcel.aspx
http://SteveOrr.net/reviews/OfficeWriter.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
http://iPhonePlaza.net

"ASF" <ro**********@g mail.comwrote in message
news:c7******** *************** ***********@z66 g2000hsc.google groups.com...
Hey all,
I have a gridview with an objectdatasourc e. I've been using the below
code to export to excel:

gvITV.AllowSort ing = False
gvITV.DataBind( )
Dim tw As New IO.StringWriter ()
Dim hw As New System.Web.UI.H tmlTextWriter(t w)
Dim frm As HtmlForm = New HtmlForm()
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.AddHea der("content-disposition",
"attachment;fil ename=export.xl s")
Response.Charse t = ""
EnableViewState = False
Controls.Add(fr m)
frm.Controls.Ad d(gvITV)
frm.RenderContr ol(hw)
Response.Write( tw.ToString())
Response.End()
gvITV.AllowSort ing = True
gvITV.DataBind( )

However, I dislike that I have to pull from the Gridview at all. I
should be able to skip the gridview binding and pull directly from the
objectdatasourc e, but I haven't been able to discover a way to do
this. Does anyone have any suggestions?
Jun 27 '08 #2
ASF
Hi Steve,

Your articles are informative, but you may have misunderstood my
question. I want to pull directly from the objectdatasourc e to excel
but I haven't discerned how to access the ODS datatable in the
codebehind. Thoughts?

Thanks

On Jun 20, 9:29*pm, "Steve C. Orr [MCSD, MVP, CSM, ASP Insider]"
<St...@Orr.netw rote:
I've documented a number of ways to export data to Excel:http://SteveOrr.net/articles/ExcelEx...portPanel.aspx

If your needs turn out to be more advanced, you might want to invest in a
good 3rd party component such as one of these:http://SteveOrr.net/reviews/AsposeEx...iceWriter.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsiderhttp://SteveOrr.nethtt p://iPhonePlaza.net

"ASF" <roy.ander...@g mail.comwrote in message
Hey all,
I have a gridview with an objectdatasourc e. I've been using the below
code to export to excel:
* * * * * *gvITV.AllowSor ting = False
* * * * * *gvITV.DataBind ()
* * * * * *Dim tw As New IO.StringWriter ()
* * * * * *Dim hw As New System.Web.UI.H tmlTextWriter(t w)
* * * * * *Dim frm As HtmlForm = New HtmlForm()
* * * * * *Response.Conte ntType = "applicatio n/vnd.ms-excel"
* * * * * *Response.AddHe ader("content-disposition",
"attachment;fil ename=export.xl s")
* * * * * *Response.Chars et = ""
* * * * * *EnableViewStat e = False
* * * * * *Controls.Add(f rm)
* * * * * *frm.Controls.A dd(gvITV)
* * * * * *frm.RenderCont rol(hw)
* * * * * *Response.Write (tw.ToString())
* * * * * *Response.End()
* * * * * *gvITV.AllowSor ting = True
* * * * * *gvITV.DataBind ()
However, I dislike that I have to pull from the Gridview at all. I
should be able to skip the gridview binding and pull directly from the
objectdatasourc e, but I haven't been able to discover a way to do
this. Does anyone have any suggestions?
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9237
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works only exporting to single worksheet. but i need to export data to multiple worksheets. it is very urgent to us. so please help me in code.
4
3942
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear" TEXT field that contains data such as 2000/01, 2001/02, etc. If I export a Query with this kind of data to Excel, it gives me the text value of this field; however, when I export a Report bound to this TEXT field, Excel gives me the values 36526,...
2
7994
by: Kenneth | last post by:
How do I remove the limitation in Access that deny me from exporting 24000 rows and 17 columns (in a query) into Excel? Kenneth
2
1764
by: Michael | last post by:
I need to be able to export data from a web form into MS Excel. I know you can do it with a VB.net windows application, but how can you do it with an asp.net application using vb.net? Any help would be appreciated! Michael
2
6920
by: Mustufa Baig | last post by:
Hi everybody, I have an ASP.NET website where clients can view their monthly billings by selecting different options. One of the option is the way they want to see the report i.e. whether they want to see it in PDF or EXCEL etc etc..... What I am trying to acheive is depending on their choice of format, I want to send the stream of that particulae selected format to the browser. I have tried couple od solutions but I couldn't able to get...
1
3157
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream As System.IO.MemoryStream = 3 myReport.ExportToStream( ExportFormatType.PortableDocFormat) 4 Response.Clear() 5 Response.Buffer() = True
2
2402
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform exporting ALL data from the datagrid control. Exporting data works fine when I show all data on the datagrid control. I'd like to shows only 30 records on the datagrid control instead of ALL data using page navigation, and perform exporting...
2
3170
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to set this up so as to do it reliably and minimize overhead? There are currently no constraints on the destination table. Assume the user or some configuration specifies the database name, server name, and filename+fullpath. The server is SQL...
1
1850
by: Jason.A.Oliver | last post by:
Hi everyone, Quick question. I'm very much a beginner with Access so I'm sorry if there's an easy way that I missed. I have several fairly large tables that I am trying to export from Access into SPSS for analysis. I haven't found a way to go directly from Access to SPSS so what I have been doing is exporting to Excel and then opening SPSS and importing the Excel file. This works fine for MOST things, except my time variables.
0
8642
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7203
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5576
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.