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

Headers only exported to Excel

10 Answers 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
bdk0172
Top achievements
Rank 1
bdk0172 asked on 15 Oct 2008, 10:42 PM
I followed your example on how to export to Excel and how to handle when the radGrid is in an ajaxified updatepanel.  The grid is populated during a button click and not during page load so it is empty when first going to the page. 

This is the code I have in another button click:

radGridResults.ExportSettings.IgnorePaging = true;

radGridResults.ExportSettings.OpenInNewWindow = true;

radGridResults.MasterTableView.ExportToExcel();

I click on the button, get the Open/Save/Cancel window and save the file.  When I open it, I first get a window popped up that states "The file you are trying to open, 'RadGridExport.xls', is in a different format than specified by the file extension.  Verify that the file is not corrupted and is from a trusted source before opening the file.  Do you want to open the file now?".  I selected Yes and when it finally opens all I can see are the header titles, it does not appear that any of the row data has been exported.

What am I doing wrong?

 

 

10 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 16 Oct 2008, 07:12 AM
Hello Brian,

Regarding the empty lines: Could you please post your RadGrid declaration?

The message you mentioned is expected and it is depicted in our documentation:
Only MS Word and MS Excel 2003 or later are supported.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
bdk0172
Top achievements
Rank 1
answered on 16 Oct 2008, 12:40 PM
<telerik:RadGrid ID="radGridResults" runat="server" Height="275px" Width="700px"   
                        EnableViewState="false" OnExcelMLExportStylesCreated="radGridResults_ExcelMLExportStylesCreated" 
                        OnExcelMLExportRowCreated="radGridResults_ExcelMLExportRowCreated">  
                    </telerik:RadGrid> 

I'm not completely sure if I need the OnExcel... events or not, I just copied them from the sample.
0
Daniel
Telerik team
answered on 16 Oct 2008, 01:02 PM
Hello Brian,

Is it working as expected with ViewState enabled?

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
bdk0172
Top achievements
Rank 1
answered on 16 Oct 2008, 01:05 PM
No, if I set it to true, then I get the following error:

Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
0
bdk0172
Top achievements
Rank 1
answered on 16 Oct 2008, 06:33 PM
Any details on this?
0
Daniel
Telerik team
answered on 17 Oct 2008, 05:21 PM
Hello Brian,

The best option would be to send us a simple working project in order to run and examine your code locally. Thus we may be able to give you a satisfying answer.

Thank you for the cooperation

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
bdk0172
Top achievements
Rank 1
answered on 17 Oct 2008, 07:03 PM
Sample is attached to support ticket number 168466.  It was created in VS 2005 and I have Office 2007 installed.
0
Sebastian
Telerik team
answered on 20 Oct 2008, 06:55 AM
Hi bdk0172,

Thank you for submitting the example - we will review it and will get back to you with more info on the subject.

Best regards,
Daniel,
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
bdk0172
Top achievements
Rank 1
answered on 20 Oct 2008, 02:26 PM
Got your example and was able to update so I can export all of the rows.  Thanks for all of your help.  One last issue which is probably just some property that needs to be set.  I have some very long numbers such as "02021418888555" which gets converted to "2.02142E+12" and time fields where "12:13:00.000" gets converted to "13:00.0".  This is what they look like in the cells, but when I select an individual cell, the proper formatting shows in the Formula Bar. 

Does this have anything to do with the fact that I'm opening the file in Excel 2007 or is it just a setting of the grid export.  Once this has been figured out, all of my issues will have been solved.

Once again, thanks for your help.
0
Daniel
Telerik team
answered on 21 Oct 2008, 04:12 PM
Hello Brian,

This behavior was already discussed in several forum threads. Here is an example:
Leading Zero's - Export to Excel

<telerik:GridBoundColumn DataFormatString="&nbsp;{0}&nbsp;" DataField="Id"></telerik:GridBoundColumn>  

I hope my directions are helpful.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
bdk0172
Top achievements
Rank 1
Answers by
Daniel
Telerik team
bdk0172
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or