Click here to Skip to main content
Licence 
First Posted 30 Jul 2005
Views 128,595
Bookmarked 57 times

DataSet to Excel in Two steps – with Different Styles

By | 30 Jul 2005 | Article
Cool Component exports DataSet(s) to Excel as Row-wise,Column-wise or Sheet-wise.
 
Part of The SQL Zone sponsored by
See Also

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);

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Krishna_accent



United Arab Emirates United Arab Emirates

Member

Software Engineer from India,Working in .NET for 2 years.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionThe Solution works great but.. PinmemberPooja H Borhade21:02 1 Nov '11  
QuestionWell Done! PinmemberTadesse11:06 21 Jun '11  
GeneralMy vote of 1 Pinmembernavbingo200:52 26 May '11  
QuestionErrors when compiling your source code in Visual Studio 2010 Pinmembermoiztankiwala10:29 10 Jun '10  
AnswerRe: Errors when compiling your source code in Visual Studio 2010 PinmemberTadesse10:52 21 Jun '11  
Generalthank's!, works if Pinmembercheluskis10:03 10 Sep '09  
Questionformulas PinmemberSilentSage3:48 31 Dec '08  
QuestionExcel Export Pinmemberdrshreya9:02 18 Sep '08  
GeneralYou are really the best Pinmemberminatharwat11:55 23 Jan '07  
GeneralTakes ages .... Pinmemberoobject20:19 5 Sep '06  
GeneralRe: Takes ages .... [modified] PinmemberTim Schwallie10:01 30 Jan '07  
GeneralRe: Takes ages .... PinmemberTim Schwallie4:20 31 Jan '07  
GeneralRe: Takes ages .... PinmemberCikaPero21:27 28 Feb '10  
QuestionApplication will not open but process does open PinmemberMariaelisau9:50 6 Jul '06  
GeneralSpecifing Excel File Name PinmemberAli Hussian Al-Faraj21:20 6 Jun '06  
GeneralAssemblies missing Pinmemberlbispo5:30 4 May '06  
Hi , thanks for your article .
 
When i try to use, i received this message
 
namespace name 'Excel' is missing
namespace name 'VBIDE' is missing
 
where i can find this assemblies ?
 

best Regards

 

Lucio Bispo(lbispo@hsbc.com.br)
GeneralAccess Denied error Pinmembersrichikka23:01 2 May '06  
GeneralRe: Access Denied error PinmemberMukesh_B22:36 27 Aug '06  
GeneralAccess is denied. Pinmemberoneforall20128:53 28 Apr '06  
QuestionWhere's the article? Pinmemberexhaulted23:03 21 Feb '06  
GeneralAccess is denied PinmemberL. Des Lierres8:01 21 Feb '06  
GeneralRe: Access is denied PinmemberL. Des Lierres14:08 28 Feb '06  
GeneralRe: Access is denied PinmemberL. Des Lierres8:28 29 Jun '06  
GeneralRe: Access is denied PinmemberL. Des Lierres8:29 29 Jun '06  
GeneralThis article is excellent PinmemberTigger9916:39 7 Feb '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120529.1 | Last Updated 31 Jul 2005
Article Copyright 2005 by Krishna_accent
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid