6

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?

Community
  • 1
  • 1
Caveatrob
  • 12,667
  • 32
  • 107
  • 187
  • What Excel features do you need? Do you just want to dump the data into an excel format or do you need charts or formulates, etc? – Zack May 29 '09 at 18:22

4 Answers4

13

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
  • 33,668
  • 7
  • 97
  • 131
7

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

Galwegian
  • 41,475
  • 16
  • 112
  • 158
  • 1
    +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 May 27 '09 at 08:58
  • customers unfortunately dont always want that – Perpetualcoder May 27 '09 at 09:39
  • 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 May 27 '09 at 09:56
  • 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 May 27 '09 at 10:20
  • ok fellas. side question - what's the best free option for delivering data from a web page if not csv? XML? – Cheeso May 29 '09 at 16:41
5

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.

Tamas Czinege
  • 118,853
  • 40
  • 150
  • 176
3

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.

Community
  • 1
  • 1
Neil Barnwell
  • 41,080
  • 29
  • 148
  • 220
  • Wouldn't that still require Excel to be installed on the machine? – Kieveli May 27 '09 at 17:18
  • 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 May 29 '09 at 14:40
  • using the OleDbConnection to create or fill an Excel file with data does not Excel to be installed on the machine. – Cheeso May 29 '09 at 16:36