Exporting Datagrid to Excel

  • Thread starter Thread starter Stephen Noronha
  • Start date Start date
S

Stephen Noronha

Hi,

I found an very interesting article on converting Datagrids to Excel. I
apologize that I forgot the name of the author/article but it was very
helpful.

Problem:
it converts only the current page on the Datgrid to Excel and if there are
other pages it does not.

does anyone have an article or sample code that converts all data from
datagrid to Excel? i have like 10 pages and it does 1 only.

Thanks all,
Stephen
 
¤ Hi,
¤
¤ I found an very interesting article on converting Datagrids to Excel. I
¤ apologize that I forgot the name of the author/article but it was very
¤ helpful.
¤
¤ Problem:
¤ it converts only the current page on the Datgrid to Excel and if there are
¤ other pages it does not.
¤
¤ does anyone have an article or sample code that converts all data from
¤ datagrid to Excel? i have like 10 pages and it does 1 only.

Technically not all of the data is *in* the DataGrid. You probably want to export from the
underlying data source which would be the DataSet or database.

http://www.dotnetjohn.com/articles.aspx?articleid=36


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Or, you can just do it the easy way by giving a user a link to a page
that renders similar to the following -- let their copy of Excel do the
rendering:

<%@ Page Language="C#"%>
<script runat=server>
void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "application/vnd.ms-excel";
}
</script>
<table>
<tr>
<td><b>Column 1</b></td>
<td style="width: 300px;"><b>Column 2</b></td>
</tr>
<tr>
<td style="background-color: yellow; color: red;">Value</td>
<td>Another Value</td>
</tr>
</table>

-Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top