Error When Un-loading Windows form

Hi I have problem when Un-loading some form after loading (displaying) an excel file , after closing the file and if I want to Un-load the form that opens the excel file sheet it gives me the following run time error : An unhandled exception of type ''Syncfusion.ExcelRW.ExcelWorkbookNotSavedException'' occurred in syncfusion.excelrw.dll Additional information: Excel Binary workbook was not saved. Object can not be disposed. Save workbook or set property ThrowNotSavedOnDestoy to false. Here is my code in case of saving the excel file: excelEngine.ThrowNotSavedOnDestroy = true; //SheetAll.Protect("syncfusion"); myWorkbook.SaveAs(Application.StartupPath + @"\\Reports\\repStatTypeDept.xls"); excelEngine.Dispose(); //Launching the Excel file using the default Application.[MS Excel Or Free ExcelViewer] System.Diagnostics.Process.Start(Application.StartupPath + @"\\Reports\\repStatTypeDept.xls"); The Excelrw version Is (2.1.0.9). So how I can avoid this error?

4 Replies

AD Administrator Syncfusion Team September 14, 2005 04:52 AM UTC

>Hi > >I have problem when Un-loading some form after loading (displaying) an excel file , after closing the file and if I want to Un-load the form that opens the excel file sheet it gives me the following run time error : > >An unhandled exception of type ''Syncfusion.ExcelRW.ExcelWorkbookNotSavedException'' occurred in syncfusion.excelrw.dll > >Additional information: Excel Binary workbook was not saved. Object can not be disposed. Save workbook or set property ThrowNotSavedOnDestoy to false. > >Here is my code in case of saving the excel file: > >excelEngine.ThrowNotSavedOnDestroy = true; >//SheetAll.Protect("syncfusion"); >myWorkbook.SaveAs(Application.StartupPath + @"\\Reports\\repStatTypeDept.xls"); >excelEngine.Dispose(); >//Launching the Excel file using the default Application.[MS Excel Or Free ExcelViewer] >System.Diagnostics.Process.Start(Application.StartupPath + @"\\Reports\\repStatTypeDept.xls"); > >The Excelrw version Is (2.1.0.9). >So how I can avoid this error? > First way: excelEngine.ThrowNotSavedOnDestroy = false; Second way: catch the exception ;)


AD Administrator Syncfusion Team September 14, 2005 10:57 AM UTC

Hi Mohammad, Change the Code as: excelEngine.ThrowNotSavedOnDestroy = false; This line throws no exception if there are unsaved workbooks. Best Regards, Seetha >Hi > >I have problem when Un-loading some form after loading (displaying) an excel file , after closing the file and if I want to Un-load the form that opens the excel file sheet it gives me the following run time error : > >An unhandled exception of type ''Syncfusion.ExcelRW.ExcelWorkbookNotSavedException'' occurred in syncfusion.excelrw.dll > >Additional information: Excel Binary workbook was not saved. Object can not be disposed. Save workbook or set property ThrowNotSavedOnDestoy to false. > >Here is my code in case of saving the excel file: > >excelEngine.ThrowNotSavedOnDestroy = true; >//SheetAll.Protect("syncfusion"); >myWorkbook.SaveAs(Application.StartupPath + @"\\Reports\\repStatTypeDept.xls"); >excelEngine.Dispose(); >//Launching the Excel file using the default Application.[MS Excel Or Free ExcelViewer] >System.Diagnostics.Process.Start(Application.StartupPath + @"\\Reports\\repStatTypeDept.xls"); > >The Excelrw version Is (2.1.0.9). >So how I can avoid this error? >


MA Mohammad Abdullah September 17, 2005 08:10 AM UTC

I did your recommendations but nothing changed the problem not resolved and the same message displayed.


AD Administrator Syncfusion Team September 19, 2005 09:16 AM UTC

Hi Mohammad, I tested with the version 2.1.0.9, it works fine. Can you please send me the file. Sorry for the Inconvenience. Thanks, Seetha >I did your recommendations but nothing changed the problem not resolved and the same message displayed.

Loader.
Up arrow icon