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.