tags:

views:

2000

answers:

4

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?

+6  A: 

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

Galwegian
+1. When just dumping data, csv is a nice way to go. Especially since you then can load it easily into applications that doesn't read excel as well.
Svish
customers unfortunately dont always want that
Perpetualcoder
indeed not what the OP was asking for. CSV is an alternative since Excel can import it, but imho not the _best free_ option.
Peter Lillevold
Yes, not the best free option, BUT maybe the most flexible option given that the OP works in an academic environment and the output can be read on any machine with or without Excel installed. Why lock yourself in to a data viewer when you don't have to..?
Galwegian
ok fellas. side question - what's the best free option for delivering data from a web page if not csv? XML?
Cheeso
+4  A: 

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.

DrJokepu
+9  A: 

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.

Peter Lillevold
+1 : we use this one and it works like a charm :)
Olivier PAYEN
Just to be clear "the new XML-based format" isn't Office Open XML (which I would call "new"). It's MS Office XML. http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats
Richard Morgan
+2  A: 

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.

Neil Barnwell
Wouldn't that still require Excel to be installed on the machine?
Kieveli
Not as far as I'm aware. I've used this technique on a server import application before and I don't believe we have Excel installed on our servers. Give it a try.
Neil Barnwell
using the OleDbConnection to create or fill an Excel file with data does not Excel to be installed on the machine.
Cheeso