Computing.Net > Forums > Programming > export to excel VB.NET 2

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

export to excel VB.NET 2

Reply to Message Icon

Name: bexm
Date: March 31, 2006 at 07:03:13 Pacific
OS: xp
CPU/Ram: 512
Comment:

Hello

I am trying to export a datagrid to an excel file using VB.NET.
I can do it in ASP.net like this:
Dim oDS As DataSet = reports.GetDataset(StoredProcedure, oparams)
Dim DG As New DataGrid
DG.DataSource = oDS
DG.DataBind()
Dim stringWrite As New System.IO.StringWriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
DG.RenderControl(htmlWrite)
reports.WriteFile(stringWrite.ToString, FileName)

(where reports contains all my functions)

but this method doesnt work in VB.NET as these two lines cannot be used in VB.NET:
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
DG.RenderControl(htmlWrite)

Does any one know of an alternative cos I'm stuck!


Thanx

Bex



Sponsored Link
Ads by Google

Response Number 1
Name: bexm
Date: April 3, 2006 at 07:03:37 Pacific
Reply:

Ok.. worked it out... did not realise I could reference the system.web namespace in a vb.net app... I can use the code listed above! duh!


0
Reply to Message Icon

Related Posts

See More


Good question Batch File- Subfolder as ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: export to excel VB.NET 2

c++.net to either VB.net or c# www.computing.net/answers/programming/cnet-to-either-vbnet-or-c/397.html

link excel chart to vb.net www.computing.net/answers/programming/link-excel-chart-to-vbnet/14244.html

Adding blank row in excel VB.NET www.computing.net/answers/programming/adding-blank-row-in-excel-vbnet/10545.html