Tutorial :Best free Excel writer for C# to output datatable to excel



Question:

I've got a console app that loads up a datatable; I'd like to export that to an Excel format and attach it to an email that's sent out on a regular basis.

What is the best library to do so that I can pull down for free? I'm working for an academic institution and we don't have a budget for third-party controls.


possible related question: How to store data to Excel from DataSet without going cell-by-cell?


Solution:1

Another free lib is CarlosAg Excel Xml Writer Library. Supports the new xml-based format.

Clarification: as we are talking about MS Excel here the new xml-based format is MS Office XML.


Solution:2

I would just write a CSV file to the hard drive.


Solution:3

I usually use MyXls when I can't use commercial tools for some reason.

Shameless self-promotion: You could have a look at my SpreadsheetFactory tool, which is a tool designed to make exporting IEnumerable collections to spreadsheets easier. It is using MyXls as underlying xls engine.


Solution:4

You can just use a ODBCConnection with the connection string specifying the spreadsheet file.

EDIT: This does not require Excel on the server machine. It will produce an .xls file that can be readable on the client machine with MS Excel.

see How to store data to Excel from DataSet without going cell-by-cell? for more detail.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »