Save Dataset As Excel File C#

Posted on
Save Dataset As Excel File C# 5,0/5 8231 reviews
  1. C# Write Dataset To File
  2. C# Save Dataset To Excel
  3. Excel File Download

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.

This article is helpful for those who would like to write dataset contents to a excel file and try to display it in the browser.

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

C# Write Dataset To File

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)

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

Asianet serial parasparam today episode. code behind

C# Save Dataset To Excel

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


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

Airmagnet survey pro license cracker. This is critical not only for guaranteeing the highest level of user satisfaction, but also helps wireless 802.11n site survey users like System Integrators maintain their margins on a project and maximizes the chances of getting repeat business. The end result is a complete Wi-Fi “weather map” of all critical RF and end-user performance metrics helping users deploy the network correctly the first time and prevent costly rework & IT complaints.

MariamMariam

Excel File Download

Contacts

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.