because the selected file is open and being used in another
window. Close it and try again.");
return Save(excel,
openContainingFolder, suggestedFileName);
}
return true;
}
else
{
return false;
}
}
On the second save attempt (after the file that was open in another
Excel window was closed), the Excel.Save method throws the following
System.Exception: “The same worksheet name already exists”.
This exception doesn’t seem to be caused by Aspose.Excel. Please debug into your program to see what’s the exact reason. If you cannot find the clue, please post your project here. I will check it ASAP.
at System.Collections.SortedList.Add(Object key, Object value)
at Aspose.Excel.Worksheets.֟(FileFormatType ֝)
at Aspose.Excel.Worksheets.֞(String ֡, SaveType ֢, FileFormatType ֝, HttpResponse ֣)
at Aspose.Excel.Excel.Save(String fileName, FileFormatType fileFormatType)
at Application.Dialogs.ExportDialog.Save(Excel excel, Boolean
openContainingFolder, String suggestedFileName)
at Application.Dialogs.ExportDialog.Save(Excel excel, Boolean
openContainingFolder, String suggestedFileName)
at Application.Dialogs.ExportDialog.buttonDownload_Click(Object
sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethod
Looks like there’s some strange code in Excel.Save that doesn’t clean
up properly, so that on the second attempt it’s trying to add an object
with a key that already exists.
Unfortunately, I can’t paste the current project, but I can try to
duplicate the error in a seperate project, if you like. Let me
know.
Hi Laurence, Sorry about the long wait, we’ve been busy. I’ve
attached a Project that can reproduce the bug described above.
The steps to produce it are:
Build & Run the project and save a test excel file with the dialog.
Open the excel file in Excel, leaving it open.
Run the project again and save the excel file as the same file
again, to overwrite the file that is open in Excel. It will throw
an IOException that will be caught by the code, which shows the dialog
again, allowing the user to close the file before saving.
Close the file in Excel.
Save the file in the dialog (as the same file).
Hope this helps. Any questions, please don’t hesitate to contact me: