Save Dataset As Excel File C#

Posted on -
Save Dataset As Excel File C# 5,8/10 7996 votes
  1. Excel File Extension
  2. Save Text File As Excel File

I have an old website developed in asp.net 2.0 and C#, I want to save data from database or DataTable To Excel File.

How to export DataTable to Excel file in C# and VB.NET: Concept. EasyXLS™ library allows you to export a DataTable to an Excel file. The data in cells can be formatted using predefined formats or user-defined formats.

Save

I searched a lot in the internet but ONLY found solutions using the HttpResponce 'Responce.Write' but this solution will not work if the file is big so I want a solution to save the excel file physically on the hard drive.

MariamMariam

3 Answers

In most cases you would even need to have MS Excel installed in the machine where you want to run your application, in order to use Excel related libraries (ie Microsoft.Office.Interop namespace).Could you use CSV files? This could be much simpler. Just load your DataTable object into a FileStream then save the file.

WPalombiniWPalombini

What environment do you have there, which version of Excel the result file should target to? Depending on that, the answer can be different. But more or less generic one - try to use GemBox.Spreadsheet, which doesn't require Excel to be installed but it has limitations in the free version.

drcolombodrcolombo

i found the solution if i have no Excel installed on the machine and decided to share it with public

Solution 1 (if you need to save the excel file physically on the hard disk)

C# save datatable to excel

you will need a gridview to put the data in it first without any css or styles just get the selected data from database with the format you need on excel file

code behind

Just Note you need to make the GridView visible true first to render it to file if it is visible false then nothing to render then you can make it false again as it is used only to hold data then render it to file Descargar visual basic 6.0 gratis.


Solution 2 (if you need to just create the file on the fly then just download it to client directly)

Buy BSAVA Manual of Exotic Pet and Wildlife Nursing (BSAVA British Small Animal Veterinary Association) 1 by Molly Varga, Rachel Lumbis, Lucy Gott (ISBN:. Manual of exotic pet practice.

Just note that i found these functions on my search but i don't try then as i need the first solution but only wanted to share the other solution for public as well

MariamMariam

Not the answer you're looking for? Browse other questions tagged c#asp.netexport-to-excelc#-2.0asp.net-2.0 or ask your own question.

I have an old website developed in asp.net 2.0 and C#, I want to save data from database or DataTable To Excel File.

I searched a lot in the internet but ONLY found solutions using the HttpResponce 'Responce.Write' but this solution will not work if the file is big so I want a solution to save the excel file physically on the hard drive.

MariamMariam

3 Answers

In most cases you would even need to have MS Excel installed in the machine where you want to run your application, in order to use Excel related libraries (ie Microsoft.Office.Interop namespace).Could you use CSV files? This could be much simpler. Just load your DataTable object into a FileStream then save the file.

WPalombiniWPalombini

What environment do you have there, which version of Excel the result file should target to? Depending on that, the answer can be different. But more or less generic one - try to use GemBox.Spreadsheet, which doesn't require Excel to be installed but it has limitations in the free version.

drcolombodrcolombo

Excel File Extension

i found the solution if i have no Excel installed on the machine and decided to share it with public

Solution 1 (if you need to save the excel file physically on the hard disk)

you will need a gridview to put the data in it first without any css or styles just get the selected data from database with the format you need on excel file

code behind

Just Note you need to make the GridView visible true first to render it to file if it is visible false then nothing to render then you can make it false again as it is used only to hold data then render it to file


Save Text File As Excel File

Solution 2 (if you need to just create the file on the fly then just download it to client directly)

Just note that i found these functions on my search but i don't try then as i need the first solution but only wanted to share the other solution for public as well

MariamMariam

Not the answer you're looking for? Browse other questions tagged c#asp.netexport-to-excelc#-2.0asp.net-2.0 or ask your own question.