We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Can not create compound file

Thread ID:

Created:

Updated:

Platform:

Replies:

19000 Sep 15,2004 03:15 PM UTC Aug 18,2008 09:04 AM UTC WinForms 11
loading
Tags: XlsIO
Richard Brown
Asked On September 15, 2004 03:15 PM UTC

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? Thanks, Rich

Administrator [Syncfusion]
Replied On September 15, 2004 03:43 PM UTC

Hi Rich, 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. Best regards, Stephen. >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? > >Thanks, >Rich >

Administrator [Syncfusion]
Replied On December 14, 2005 03:18 PM UTC

Hi! Stephen, 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? Please help! Thanks, Bhandhavi. 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)

Administrator [Syncfusion]
Replied On December 15, 2005 12:59 PM UTC

Hi Bandhavi, 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 try { myWorkbook.SaveAs("Sample.xls"); } 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. Thanks, Stephen.

Administrator [Syncfusion]
Replied On December 15, 2005 03:32 PM UTC

Thanks, Stephen, It worked. One more question, what if the user wants to overwrite already opened file. Try myWorkBook.SaveAs("sample.xls") 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 End Try

Administrator [Syncfusion]
Replied On December 15, 2005 08:21 PM UTC

Hi Bandhavi, I am afraid this would not be possible since there seems to be no way overwrite any file that is locked by another application. Thanks, Stephen. >Thanks, Stephen, > >It worked. One more question, what if the user wants to overwrite already opened file. > >Try > myWorkBook.SaveAs("sample.xls") >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 >End Try >

Administrator [Syncfusion]
Replied On December 16, 2005 06:46 PM UTC

No problem! I just wanted to know, just in case users would ask for something like that. Thanks, Bhandhavi.

Ichiro Sugimoto
Replied On March 10, 2008 11:15 AM UTC

I'm using Essential Studio 6.1.0.34, 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:

Syncfusion.XlsIO.IO.Stream.StgStream.CreateStorage(String fileName)
Syncfusion.XlsIO.Implementation.WorkbookImpl.WorkbookExcel97Serializator.CreateOrOpenStorage(String path, WorkbookImpl book)
Syncfusion.XlsIO.Implementation.WorkbookImpl.WorkbookExcel97Serializator.Serialize(String fullName, WorkbookImpl book, ExcelSaveType saveType)
Syncfusion.XlsIO.Implementation.WorkbookImpl.SaveAs(String FileName, ExcelSaveType saveType, ExcelVersion version)
Syncfusion.XlsIO.Implementation.WorkbookImpl.SaveAs(String FileName)

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:

System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
System.IO.File.Delete(String path)
Syncfusion.XlsIO.Implementation.WorkbookImpl.SaveAs(String FileName, ExcelSaveType saveType, ExcelVersion version)
Syncfusion.XlsIO.Implementation.WorkbookImpl.SaveAs(String FileName)

What is the difference of the condition in which these exceptions are thrown?


Administrator [Syncfusion]
Replied On March 13, 2008 10:46 AM UTC

Hi Ichiro,

Thank you for your update.

System.Runtime.InteropSevices.ExternalException:

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

Regards,
G.Yavana




Dennis Horan
Replied On July 23, 2008 02:25 PM UTC

Hi Ichiro,

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.

Dennis Horan






Yavanaarasi G [Syncfusion]
Replied On July 28, 2008 03:35 AM UTC

Hi Dennis,

Thanks for sharing your ideas.

Please let me know if you have any other concerns.

Regards,
G.Yavana


Ichiro Sugimoto
Replied On August 18, 2008 09:04 AM UTC

Hi Yavana,

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.


Regards,
Ichiro


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;