Question

I want to export TVP (Type of DataTable) to .csv file, or .xls, but more to .csv using aspx. Can you help me with this questuion?

Était-ce utile?

La solution

There is a lot of ways by which you can achieve this. Just take a look into my blog. I specified 3 ways of doing it in my article.

  • RenderControl
  • HTML Table
  • OLEDB

These are the ways of doing it without using the Interop.


How to format my data during export time, for example color rows, columns, headers and so on.

For this, I would like to quote these from my blog.

RenderControl

Using this approach, we can easily export the data from GridView. This will be useful when we want our exported data in the same format as in the GridView.

Format your grid as required and invoke its RenderControl method. This will export style along with the data.

HTML Table

Here the sheets are treated as a html table. The advantage of this approach is easy customization. You can customize the output using any html tags.

Wrap data with html style elements and render it.

Autres conseils

Simply bind your data to DataGrid and render page with Response.ContentType = "application/vnd.ms-excel";

For further take a look this

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top