I''m getting this exception, System.Runtime.InteropServices.ExternalException: Can not create compound file, when I do a .SaveAS(filename) on a workbook. This is from a .NET Web app. Has anyone else had this problem?
ADAdministrator Syncfusion Team September 15, 2004 11:43 AM
This generally happens when you already have an Excel file open with the same name. For example, if you have a file called "Sample.xls" open and you try to overwrite that file, then you will get this "cannot create compound file" exception. If this is not the case, could you please provide more information or provide a sample if possible. Thanks.
>I''m getting this exception, System.Runtime.InteropServices.ExternalException: Can not create compound file, when I do a .SaveAS(filename) on a workbook. This is from a .NET Web app. Has anyone else had this problem?
ADAdministrator Syncfusion Team December 14, 2005 10:18 AM
I am getting the same error message. Actually, I am trying to overwrite an existing file. But the existing file is already opened.
How should I handle or catch this exception?
Can not create compound file.
at Syncfusion.ExcelRW.IO.Stream.StgStream.CreateStorage(String fileName)
at Syncfusion.ExcelRW.Implementation.WorkbookImpl.CreateOrOpenStorage(String path)
at Syncfusion.ExcelRW.Implementation.WorkbookImpl.SaveAs(String FileName, ExcelSaveType saveType)
at Syncfusion.ExcelRW.Implementation.WorkbookImpl.SaveAs(String FileName)
ADAdministrator Syncfusion Team December 15, 2005 07:59 AM
Here is some sample code to check for an excel file that already exists and is open by excel and also to prompt the user to save their changes to a different file before we overwrite it
catch (System.Runtime.InteropServices.ExternalException ex)
if(ex.ErrorCode == -2147287007)
MessageBox.Show("The file that you are trying to create is already open","File is Open");
Please let me know if you have any questions.
ADAdministrator Syncfusion Team December 15, 2005 10:32 AM
It worked. One more question, what if the user wants to overwrite already opened file.
Catch ex As System.Runtime.InteropServices.ExternalException
If ex.ErrorCode = -2147287007 Then
If MessageBox.Show("The file sample.xls is already opened. Are you sure you want to overwrite it?","", ) = YES Then
''Overwrite existing opened file
ADAdministrator Syncfusion Team December 15, 2005 03:21 PM
I am afraid this would not be possible since there seems to be no way overwrite any file that is locked by another application.
>It worked. One more question, what if the user wants to overwrite already opened file.
>Catch ex As System.Runtime.InteropServices.ExternalException
> If ex.ErrorCode = -2147287007 Then
> If MessageBox.Show("The file sample.xls is already opened. Are you sure you want to overwrite it?","", ) = YES Then
> ''Overwrite existing opened file
> End If
ADAdministrator Syncfusion Team December 16, 2005 01:46 PM
No problem! I just wanted to know, just in case users would ask for something like that.
ISIchiro SugimotoMarch 10, 2008 07:15 AM
I'm using Essential Studio 188.8.131.52, and the user of my application met the same System.Runtime.InteropSevices.ExternalException in the IWorkbook.SaveAs(string) method. The stacktrace of the exception is as follows:
I tried to reproduce the issue, to overwrite the already existing Excel file which is opened. Then System.IO.IOException, not System.Runtime.InteropSevices.ExternalException, was thrown. The stacktrace is as follows:
What is the difference of the condition in which these exceptions are thrown?
ADAdministrator Syncfusion Team March 13, 2008 06:46 AM
Thank you for your update.
Please try to send us the sample and the file in which this exception is reproduced so that we could sort out the cause of the issue and provide you a solution?
Also please provide the below details: 1. Sytem configuration 2. Office version
DHDennis HoranJuly 23, 2008 10:25 AM
I just received this same error message in a .NET application, where the file was not opened. But, the IIS_WPG user group did not have write permissions to the directory where I was saving. I added the permissions and then it worked fine.
I assume that even if you have a windows application, you'll need to make sure that the user has write permissions to the directory.
Hope this helps.
YGYavanaarasi G Syncfusion Team July 27, 2008 11:35 PM
Thanks for sharing your ideas.
Please let me know if you have any other concerns.
ISIchiro SugimotoAugust 18, 2008 05:04 AM
I'm sorry for my delay response.
[1. Sytem configuration] Microsoft Windows XP Professional Version 2002 Service Pack 2
IBM Corporation Intel(R) Pentium(R) M processor 2.26GHz 2.26GHz, 2.00 GB RAM
[2. Office version] Microsoft Office Professional Edition 2003
And, this issue seems to occur only with specific (i.e. not every) exporting data.