Defect workbook after copiing one worksheet to another workbook

Hi,

I copy one worksheet form one workbook to another. An exception occurs during saving -> File corrupt.

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at Aspose.Cells.Workbook.Save(String fileName, SaveOptions saveOptions)
at Aspose.Cells.Workbook.Save(String fileName, SaveFormat saveFormat)
at IMMSGService.Aspose.ExcelHelpers.Save(Workbook workBook, String fileName)

Simple code to reproduce:

const string srcFilePath = @"C:\temp\DataTest\AsposeTest\Test22_CopyWorksheet\SrcBook.xlsm";
const string tgtFileBasePath = @"C:\temp\DataTest\AsposeTest\Test22_CopyWorksheet\TgtBookBase.xlsm";
const string tgtFilePath = @"C:\temp\DataTest\AsposeTest\Test22_CopyWorksheet\TgtBook.xlsm";
const string sheetName = "Mold1";

Workbook wbSource = new Workbook(srcFilePath);
Workbook wbTargetBase = new Workbook(tgtFileBasePath);

Worksheet sheetTgt = wbTargetBase.Worksheets.Add(sheetName);
sheetTgt.Copy(wbSource.Worksheets[sheetName]);
wbTargetBase.Save(tgtFilePath);

Files: Test22_CopyWorksheet.zip (789.7 KB)

TgtBook.xlsm is the defective one.
I am using .Net4.0

Let me know if you need more information.

@sabrinaluedtke

Thanks for using Aspose APIs.

We were able to observe this issue and logged it in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-45781 - System.ArgumentOutOfRangeException occurs when worksheet is copied to another workbook

@sabrinaluedtke

Thanks for using Aspose APIs.

This is to inform you that we have fixed your issue CELLSNET-45781 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

@sabrinaluedtke

Thanks for using Aspose APIs.

Please download and try the following fix and let us know your feedback.

@shakeel.faiz

Thanks for the fix. It works now.

@sabrinaluedtke

Thanks for your feedback. It is good to know that your issue is resolved with the latest fix. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

The issues you have found earlier (filed as CELLSNET-45781) have been fixed in this Aspose.Cells for .NET 17.12 update.

Please also check the following article: