GitXplorerGitXplorer
S

ExcelExporter

public
43 stars
10 forks
2 issues

Commits

List of commits on branch master.
Unverified
a941959618b15c766e304c312e968ee9944a0afb

Add NuSpec

SSLaks committed 13 years ago
Unverified
f23f9bfea840e91a9dacb9b8c7821b857be612be

Add readme

SSLaks committed 13 years ago
Unverified
592e3a1b1f0d2d5c095ceae70f03109192dca9b3

Improve IDataReader support

SSLaks committed 13 years ago
Unverified
90c4f7cb205613b9f8c0d3f9c0f73a75dbcbdc11

Remove usings

SSLaks committed 13 years ago
Unverified
f801b0ebff21c96da773f7d6496f12b6fdc8b73a

Add DataReader support

SSLaks committed 13 years ago
Unverified
8052a3a55cf4bf7b1833c49eab641de9ebc770bb

Validate

SSLaks committed 13 years ago

README

The README file for this repository.

#ExcelExport

ExcelExport is a simple, fluent API to export data to Excel spreadsheets. ExcelExport uses OleDb to generate Excel files (Microsoft.ACE.OLEDB for Excel 2007+ formats, and Microsoft.Jet.OLEDB for Excel 2003 .xls files)

This library can also be used to generate Excel files in ASP.Net MVC actions; use this simple ActionResult class.

##Sample usage

new ExcelExport()
	.AddSheet("Sample Names", new[] {
		new { Name = "Bill Stewart",	ZipCode = "00347", Birth_Date = new DateTime(1987, 6, 5) },
		new { Name = "Russ Porter",  	ZipCode = "04257", Birth_Date = new DateTime(1956, 7, 8) },
		new { Name = "Rodrick Rivers",	ZipCode = "19867", Birth_Date = new DateTime(1956, 7, 8) }
	})
	.AddSheet(
		"LINQ Query Sample",
		ordersQuery.Select(o => new { 
			Product_Name = o.Product.Name, 
			o.Quantity,
			o.OrderDate
		}
	)
	.AddSheet(someDataSet.Tables[0])
	.AddSheet(
		"Classic ADO.Net Sample",
		someCommand.ExecuteReader()
	)
	.ExportTo(Path.Combine(
		Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), 
		"Sample.xlsx"
	));

##Notes

  • When exporting anonymous types, _ (underscore) characters in property names will be replaced with spaces.

  • When exporting ADO.Net DataTables, the sheet name is optional; if omitted, the table's TableName property will be used instead.

  • When exporting ADO.Net DataReaders, the reader must remain open when ExportTo() is called. When the export is finished, the reader will be closed.