65.9K
CodeProject is changing. Read more.
Home

DataSet to Excel in Two steps – with Different Styles

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.46/5 (34 votes)

Jul 31, 2005

viewsIcon

251965

downloadIcon

11342

Cool Component exports DataSet(s) to Excel as Row-wise,Column-wise or Sheet-wise.

Sample Image - datasettoexcel.jpg

Introduction

This component exports a DataSet to Microsoft Excel. You can also export more than one multiple DataSets at a time. This component handles disposing of Excel objects and cleaning up of memory automatically. So there is no worry of memory leakage!! Just two lines of code to export your DataSet to Excel. This is a free component.

Note: You need Excel to be installed in your system.

Different Styles

Different styles that are available are:

  • Row Wise: Exports each DataTable in the DataSet in row-wise in Excel.
  • Column Wise: Exports each DataTable in the DataSet in column-wise in Excel.
  • Sheet Wise: Exports each DataTable in the DataSet in one worksheet.

Other features and formatting styles

You can set the following:

  • HeaderForeColor
  • HeaderBackColor
  • ItemForeColor
  • ItemBackColor
  • ItemAlternateBackColor
  • FontStyle
  • RowsSpace
  • ColumnSpace
  • TableSpace

Sample Code

Utilities.ExcelExport.Export excel = 
                    new Utilities.ExcelExport.Export();
//Pass your Dataset and Specify the style.
excel.ExportDataToExcel(yourDataSet, 
            Utilities.ExcelExport.ExportStyle.RowWise);