This is a migrated thread and some comments may be shown as answers.

ExportToExcel() very slow.

6 Answers 241 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AL
Top achievements
Rank 1
AL asked on 19 Aug 2010, 09:54 PM
Hi,

I am puzzled: Why does exporting to excel takes such a looooooooong time?

Getting data from database into a DataTable takes 5 seconds. Then I bind RadGrid to this DataTable in server side (RadGrid visible = false). Now it takes more than a minute to export it to excel (until I get the save/open file prompt). Is there any way to directly export DataTable to Excel? If, not is there any way to make export to excel much faster.

Here's the code (RadGrid's visibility is set to false, just exporting data from user selected dropdowns to excel):

            RadGrid1.AutoGenerateColumns = true;
            RadGrid1.DataSource = myDataTable; //from database
            RadGrid1.DataBind();

            RadGrid1.ExportSettings.ExportOnlyData = true;
            RadGrid1.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;           
            RadGrid1.MasterTableView.ExportToExcel();

Any help and/or suggestions is deeply appreciated!

Thanks

6 Answers, 1 is accepted

Sort by
0
AL
Top achievements
Rank 1
answered on 23 Aug 2010, 07:42 PM
Any suggestion from anyone to make export to excel faster?
0
Daniel
Telerik team
answered on 24 Aug 2010, 03:34 PM
Hello AL,

There are two ways to improve the exporting speed:
- reduce the number of columns / rows
- switch to CSV format

Another option is to export your data manually (that is to avoid the built-in export). For that purpose you can use the ExcelML format or a third-party library like NPOI.
ExcelML structure / GridExcelBuilder
NPOI @ CodePlex

Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
AL
Top achievements
Rank 1
answered on 24 Aug 2010, 03:41 PM
Hi Daniel,

I tried Export to CSV. But I only get the column headers (data part was missing). Can you help with ExportToCSV() code?

Here is my code, but data does not get exported:

            RadGrid1.AutoGenerateColumns = true;
            RadGrid1.DataSource = myDataTable; //from database
            RadGrid1.DataBind();

            RadGrid1.ExportSettings.ExportOnlyData = false;
            RadGrid1.MasterTableView.ExportToCSV();

Thanks.
0
Daniel
Telerik team
answered on 27 Aug 2010, 03:11 PM
Hello AL,

I suppose that you use GridTemplateColumns. If this is so, please post the declaration of one of those columns in this thread. This way I will be able to provide better suggestion for your scenario.

Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
AL
Top achievements
Rank 1
answered on 27 Aug 2010, 03:21 PM
Hi Daniel,

I am not using GridTemplateColumns. In fact I am not even displaying the grid (see grid visibility = false mentioned in original post).

Ok, this is what I have in aspx page:

<

 

 

telerik:RadGrid ID="RadGrid1" runat="server" Visible="false" ></telerik:RadGrid

AND this is what I have in code behind:
RadGrid1.AutoGenerateColumns = true;
            RadGrid1.DataSource = myDataTable; //from database
            RadGrid1.DataBind();

            RadGrid1.ExportSettings.ExportOnlyData = false;
            RadGrid1.MasterTableView.ExportToCSV();

I am simply populating RadGrid from codebehind and trying to export its contents to csv. Can you help?

Thanks again.

AL

0
Accepted
Daniel
Telerik team
answered on 27 Aug 2010, 09:46 PM
Hello AL,

Please modify the export method this way:
RadGrid1.AutoGenerateColumns = true;
RadGrid1.DataSource = myDataTable; //from database
 
RadGrid1.Visible = true;
 
RadGrid1.DataBind();
RadGrid1.ExportSettings.ExportOnlyData = false;
RadGrid1.MasterTableView.ExportToCSV();

Note how this modification affects the exported file only. This is because the output is redirected to the file and the page won't be changed at all.

By the way, this is listed as an unsupported scenario in our documentation:
CSV export topic

Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
AL
Top achievements
Rank 1
Answers by
AL
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or