While working on creating a console application to manipulate an Excel file using COM interop, I ran into an issue where console application would not close even after I called Quit on the Application object. There was no exception or any error throw but the console application was still waiting for close.
The problem was that I had made a change in the worksheet but I did not save the workbook after it. Excel application sees that a workbook is in Dirty state so it wants to make sure that user of the application, which in my case is a console application, saves the unsaved changes before closing the workbook. There are few options you have here.
Workbook object exposes a property Saved that can be used to check if there are any unsaved changes. If value of this property is True that means you have unsaved changes.
if (myWorkbook.Saved) { Console.Writeline("There are no unsaved changes to this workbook"); }
There may be cases where you have made some changes to some cells. That means Workbook is dirty now. But you really do not want to save the changes. If you do not take care of this, then your application will not close because Excel application instance is waiting for Workbook to be saved. You will use the same Saved property to deal with this. You can set this property to True to indicate that Workbook should be treated as saved and not prompted for saving.
if (!myWorkbook.Saved && !needToSave) { myWorkbook.Saved = true; }
This is all to how you can deal with saving or not saving of a dirty Excel Workbook.
Excel automation application not closing
Implement OWA style New message notifier poup using Silverlight
How to get notified in silverlight application when size of browser changes
How to plan CCSP Exam preparation
Develop a MongoDB pipeline to transform data into time buckets
Alert and Confirm pop up using BootBox in AngularJS
AngularJS Grouped Bar Chart and Line Chart using D3
How to lock and unlock account in Asp.Net Identity provider
2025 © Byteblocks, ALL Rights Reserved. Privacy Policy | Terms of Use