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% [?]




Fri, Jul 25, 2008
.Net Related, ADO.net, Libraries, c#