Here goes one more needy component for developers. a lot of developers always had a problem of exporting data to excel programmatically. if you Google this topic you will get many results regarding this. here are some which caught my eyes.
- How To Use ADO.NET to Retrieve and Modify Records in an Excel Workbook With Visual Basic .NET
- DataSet to Excel in Two steps – with Different Styles- by Krishna_accent
- And finally comes our good old CSV files.
the first one seems to be ok. but have little more work to be done on coding. the second is a really good one, but again we need excel to be installed, which again run out of our needs.
using CSV is ok for unformatted Comma Separated Values.
But Recently I found Carlos Aguilar Mares has this wonderful FREE component called ExcelXmlWriter , to export data to excel. it doesn’t need excel to be installed and it can be used to generate formatted excel workbooks with very few lines of code.
1: using CarlosAg.ExcelXmlWriter;
2:
3: class TestApp {
4: static void Main(string[] args) {
5: Workbook book = new Workbook();
6: Worksheet sheet = book.Worksheets.Add("Sample");
7: WorksheetRow row = sheet.Table.Rows.Add();
8: row.Cells.Add("Hello World");
9: book.Save(@"c:\test.xls");
10: }
11: }
the download has a very easy to understand help file explaining how to use this. you can download it in his website here.
Clean and simple isn’t it ?
Popularity: 100% [?]




September 26th, 2008 at 7:33 pm
This was wonderful help! Thanks! I was looking for a way to export a DataGridView’s data to Excel without needing to use the com objects, as that can be very messy. This was a lifesaver.
October 14th, 2008 at 2:48 am
try opening that in open office. and you’ll see xml structured file. I see this as a vunerability. since you can read it as plain text. I wish there’s a way to convert it to binary format. since this is a great tool.
July 13th, 2009 at 10:44 am
Hi,
For Formatting excel output, this ExcelXMLWriter is perfectly working fine.. This is taking inputs only either from DataSet or DataTable only. Not from other media. Now I want to generate a graph just below the formatted output.How to export IMAGE also into the excel sheet. Please guide me in this regard,
Karthik
September 7th, 2009 at 7:43 am
Hi pongscript, Actually it exports in Ms 2007 format. If you change the file format “xls” to “xlsx”, it will work fine.
How to export in XLS format?
Anybody…
September 25th, 2009 at 5:10 pm
I have used this to generate xls files. Later on in this vb.net2008 these xls files are being emailed (smtp) and the sent files should be moved to an archive folder.
This move operation does not work !!
Apparently the files are still locked, even though the (workbooks) excellapp has been saved, closed and quit.
Should I release these file locks using another methode ?
Johan
December 1st, 2009 at 7:12 am
Really helpfull. I hope this is work greatefully for my work.
December 18th, 2009 at 5:25 am
Good Stuff! Thanks Aneef. Hope this “CarlosAg.ExcelXmlWriter” component is trustable.
January 26th, 2010 at 7:33 am
Thanks, this is a great tool! But i need to export to Exel binary workbook files, can it do this? please show me how.