0
nimesh's Avatar, Join Date: Apr 2009
Invasive contributor
I didn't got that?
What exactly are you asking about?
0
naimish's Avatar
Banned
How did you write that code in VB 6.0 ? or have you write in VB.NET ?
0
nimesh's Avatar, Join Date: Apr 2009
Invasive contributor
ok.

That's in VB.NET

What I wanted to mention earlier is that, this code is using VB as the language and not C#
0
naimish's Avatar
Banned
Ohhk buddy, will need to check it, will tell you ASAP......!
0
nimesh's Avatar, Join Date: Apr 2009
Invasive contributor
I'm back with a problem.

I was using the approach I mentioned before to get only the gridview to excel.
till now I was happy with it but now I found that the file getting downloaded is not an excel but an html with ext xls
it opens normally without any problems, but when I save the file, it created the html's associated folder "abc_files"

Also one more problem I encountered was that the data appearing in gridview does not appear same in excel.
excel interprets the datatype and displays accordingly.
like the value 10.0 in gridview displays as 10 only in excel.

Anything that you can suggest?
0
cikaPero's Avatar, Join Date: Mar 2010
Newbie Member
There is also a much cleaner way to export DataSet to Excel with GemBox.Spreadsheet Excel .NET component:

Code:
// Create new ExcelFile.
ExcelFile ef = new ExcelFile();
                                                            
// Imports all the tables from DataSet to new file.
foreach (DataTable dataTable in dataSet.Tables)
{
     // Add new worksheet to the file.
     ExcelWorksheet ws = ef.Worksheets.Add(dataTable.TableName);
                                                            
     // Insert the data from DataTable to the worksheet starting at cell "A1".
     ws.InsertDataTable(dataTable, "A1", true);
}
                                                            
// Save the file to XLS format.
ef2.SaveXls("DataSet.xls");
0
cikaPero's Avatar, Join Date: Mar 2010
Newbie Member
Hi,

you can use GemBox.Software .NET Excel library to convert DataSet to Excel in ASP.NET applications:
Code:
// Create new ExcelFile.
var ef = new ExcelFile();

// Imports all the tables from DataSet to new file.
foreach (var dataTable in dataSet.Tables)
{
    // Add new worksheet to the file.
    var ws = ef.Worksheets.Add(dataTable.TableName);

    // Insert the data from DataTable to the worksheet starting at cell "A1".
    ws.InsertDataTable(dataTable, "A1", true);
}

// Stream file to browser.
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=Employee.xls");
ef.SaveXls(Response.OutputStream);
Response.End();