Last week we had a meeting other friends at work, they has some ideas about the enhancement of the in-house application. E.g. export the data from the in-house application to Spreadsheet, which would be very handy when you need to keep a record of the query you done or need to email the data to the client…etc. I have spent sometime in the weekend and see how to achieve that. finally, I have created a simple library to Export DataTable/ DataGridView / Grid View to Excel XLSX or PDF format.
Here is my .Net Library: “ShareChiWaiLib” at the moment it only has 1 class “XLSXHelper“, which allow user to
Export DataTable to Excel XLSX or PDF
By using XLSXHelper. ExportDataTableToXLSX() method
Export DataGridView to Excel XLSX or PDF
By using XLSXHelper. ExportDataGridViewToXLSX() method
Export GridView to Excel XLSX or PDF
By using XLSXHelper. ExportGridViewToXLSX() method
Here it is the description about this class.
Public sub Example()
“True/False — whether to includes the column header”,
“FileType — is ENUM E.g. ExportFileType.XLSX to Export XLSX Format in Excel 2007/2010
ExportFileType.PDF is for PDF Format”,
“FilePath — where you want the file export to and please ensure you have premission to write to that directory,
“FileName – Filename includes file Extension E.g. ‘.xlsx’ or ‘.pdf'”
‘are similar, therefore I will leave it to you to find out =)
Feel Free to download the Library from the URL below.
If you do not have office in you computer, you may need to download Office Primary Interop Assemblies, in order to get it work
I will try to put more feature, useful stuff on “ShareChiWaiLib” in future. I would be grateful, if you could give me some suggestion/feedback about ShareChiWaiLib and what to put in future=).
Hope you find it useful