Copying worksheet from file to file corrupts Excel file

Using Cells for Java V2.0, if you open a new workbook, copy a worksheet from another workbook to sheet 0 of the new workbook, and then save the new workbook, the new workbook is somehow corrupted. Depending on the version of Excel I use, I either get a “file corrupted” error when I open the new workbook, or an error when I try to close it (Excel needs to quit).

Creating a new worksheet, copying the worksheet from another workbook to it, and then deleting worksheet 0 from the new file seems to solve the problem.


Could you post your template file(s) with sample code here, we will check your issue soon.

Thank you.


Thank you for considering Aspose.

Well, I have executed your scenario by using the latest version of Aspose.Cells for Java and it works fine. Following is my sample code.

Sample Code:

//Create a Workbook.

Workbook excelWorkbook0 = new Workbook();

//Create another Workbook.

Workbook excelWorkbook1 = new Workbook();

//Open a file into the first book.“C:\Sample.xls”);

//Copy the first sheet of the first book into second book.


//Save the file.“C:\FinalBook.xls”, FileFormatType.DEFAULT);

Please Share your template file, so we can figure out the issue.

Thank You & Best Regards,

Here is my sample code and designer.


Thanks for providing the template file with sample code.

We have found the issue after an initial test, we will figure it out soon.

Thank you.


We have figured out your issue and fixed it, please try the new fix V2.0.0.7 (attached).

By the way, we have analyzed this issue(Copying Worksheets issue) and the Worksheets.removeSheet issue which you posted some days ago in the thread: <A href="</A> both are caused by some improper records in your original files. So, we think maybe your original files were created by some tools other than MS Excel, would you please let us know which tool(s) you used to create those files? If they were generated by Aspose.Cells for Java, please give us your codes to create such Workbooks, so we can trace the root cause of such problem and get rid of the issue next time. </P> <P>We do appreciate your help in this regard.</P> <P>Thank you.<BR></P>