Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Excel as Web Report 2

Status
Not open for further replies.

chadau

Programmer
Joined
Nov 14, 2002
Messages
155
Location
US
I need to use Excel as my reporting tool in an ASP.NET app. I have to load a spreadsheet with data from a SQL Server and display it to a client pc. First of all, has anyone done this? Secondly, how should I handle mutli user interaction with same report? Thanks in advance.
 
you can use this code to convert the value on a datagrid to excel:

if (ds1 != null )
{
// Set the content type to Excel.
Response.ContentType = "application/vnd.ms-excel";
// Remove the charset from the Content-Type header.
Response.Charset = "";

// Turn off the view state.
this.EnableViewState = false;

System.IO.StringWriter tw;
tw = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter hw;

hw = new System.Web.UI.HtmlTextWriter(tw) ;

// Get the HTML for the control.
datagrid1.RenderControl(hw);
// Write the HTML back to the browser.
Response.Write(tw.ToString());
// End the response.
Response.End();
}

you need to have a web page with a datagrid, and associate the dataset to the datagrid. the above code will convert the datagrid to an excel file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top