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

ExportToExcelML.RunExport exception

5 Answers 101 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Krtek
Top achievements
Rank 1
Krtek asked on 11 Mar 2009, 02:01 PM
Hello,
I need to export radGridView into xls file throught ExportToExcelML. For these puprose I use this code

SaveFileDialog saveDialog = new SaveFileDialog(); 
saveDialog.DefaultExt = "xls"
saveDialog.Filter = "Excel (*.xls)|*.xls"
saveDialog.OverwritePrompt = true
saveDialog.CreatePrompt = true
if (saveDialog.ShowDialog() == DialogResult.OK) 
   if (string.IsNullOrEmpty(saveDialog.FileName)) 
   { 
       MessageBox.Show("Please enter a file name."); 
       return
   } 
                 
   ExportToExcelML export = new ExportToExcelML(); 
   export.HiddenColumnOption = ExportToExcelML.HiddenOption.ExportAsHidden; 
   export.HiddenRowOption = ExportToExcelML.HiddenOption.ExportAsHidden; 
                 
   export.RunExport(bestellungRadGridView, saveDialog.FileName, ExportToExcelML.ExcelMaxRows._65536, true);                 
}    

But on the last line of code (export.RunExport(....)) I get the exception "Worksheet collection cannot be empty." and the inner exception is empty.
Is there some problem in my code or it is some general problem of ExportToExcelML class?

Thank you for your response
Petr

5 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 13 Mar 2009, 03:25 PM
Hello Krtek,

Thank you for writing.

I have managed to reproduce the same exception if the RadGridView does not contains any data rows. If your case is the same, I can recommend you check if the grid has at least one row before execute RunExport method. We will change this behavior in some of the next releases. Please let me know If your grid is not empty and send me more details on your scenario.

All the best,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Krtek
Top achievements
Rank 1
answered on 16 Mar 2009, 07:08 AM
Hello,
I checked my code and the problem is propably somewhere in
export.RunExport(bestellungRadGridView, saveDialog.FileName, ExportToExcelML.ExcelMaxRows._65536, true); 
because when debug first step on this code line the bestellungRadGridView.Rows collection contains 14 rows. But RunExport function throws exception "Worksheet collection cannot be empty" and after this exception bestellungRadGridView.Rows collection is empty. Maybe something in RunExport is wrongly clears this collection.

Thank you for your help
Petr
0
Martin Vasilev
Telerik team
answered on 18 Mar 2009, 08:09 AM
Hi Krtek,

Thank you for getting back to me. The RunExport method does not contain any code for clearing Rows collection. You are the first customer that reports such a behavior. Maybe, there is something specific in your scenario that causes the issue. Please, send me a small example project that demonstrates the exception. This will help me to investigate your case and provide further assistance. I have moved this topic to our support system so that you can attach files. I am looking forward to your project.

Regards,
Martin Vasilev
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Krtek
Top achievements
Rank 1
answered on 18 Mar 2009, 10:05 AM
Hi Martin,
thank you for you reply.

I have installed new version of telerik component and new database and problem is gone (maybe some problem in data).

Thank you for your help
Petr
0
jeff357
Top achievements
Rank 2
answered on 01 Jul 2011, 06:13 AM
Thanks man for the code
wish it was in vb.net ;)
                     Jeff L
Tags
GridView
Asked by
Krtek
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Krtek
Top achievements
Rank 1
jeff357
Top achievements
Rank 2
Share this question
or