Combining workbooks with worksheets named like R# produces corrupted workbooks

When merging two workbooks under certain conditions using Aspose.Cells version 8.2.2.0, a corrupted workbook is produced.

See attached workbooks, and code below :

Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense("Aspose.Cells.lic");

Aspose.Cells.Workbook wb1 = new Aspose.Cells.Workbook(@"C:\$Wip\MergeWorkbook1.xlsx");
Aspose.Cells.Workbook wb2 = new Aspose.Cells.Workbook(@"C:\$Wip\MergeWorkbook2.xlsx");
wb1.Combine(wb2);
wb1.Save(@"C:\$Wip\MergeOutError.xlsx", (Aspose.Cells.SaveFormat )wb1.FileFormat);

If you recover the merged workbook, you will see that range names are missing and some formula's have been stripped, replaced with a value of zero (0), or sometimes just blank.

It appears the issue is caused when a worksheet is named like R and a number (e.g. R1, R2P, etc).
I think the issue is because a worksheet named like R# has to have apostrophe's around the sheet name in the xml, otherwise Excel confuses the worksheet name as an R1C1 reference (just a guess).

See picture below.

Notice how in the MergeWorkbook1.xlsx's workbook.xml, the worksheet names are surrounded by apostrophe's, whereas the merged workbook MergeOutError.xlsx, workbook.xml does not.
This workbook's associated sheet xml's that reference R# sheets, also do not have apostrophes around the sheet name in references.

photo mergeissuexml2.png

If I manually add the apostrophe's to workbook.xml and any sheet#.xml that refer to R# named worksheets, the workbook opens without any errors.

Also, if I change the names of all worksheets like R#, the merged workbook opens fine:

static void RenameR1Sheets()
{
Aspose.Cells.Workbook wb1 = new Aspose.Cells.Workbook(@"C:\$Wip\MergeWorkbook1.xlsx");
Aspose.Cells.Workbook wb2 = new Aspose.Cells.Workbook(@"C:\$Wip\MergeWorkbook2.xlsx");

string pattern = @"^[R|r]\d+";
System.Text.RegularExpressions.Regex re = new System.Text.RegularExpressions.Regex(pattern);
wb1.Worksheets.Cast().Where(q =>re.IsMatch(q.Name)).ToList().ForEach(q => q.Name = "x" + q.Name);
wb1.Combine(wb2);
wb1.Save(@"C:\$Wip\MergeOutRename.xlsx", (Aspose.Cells.SaveFormat)wb1.FileFormat);
}

Please see "Understanding How Excel Interprets Labels"

Hi Dean,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue. After combining your workbooks, where one of your workbook has worksheets names like R#, produces corrupt output workbook.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43143 - Combining workbooks with worksheets named like R# produces corrupted workbooks

C#

Aspose.Cells.Workbook wb1 = new Aspose.Cells.Workbook(@“MergeWorkbook1.xlsx”);

Aspose.Cells.Workbook wb2 = new Aspose.Cells.Workbook(@“MergeWorkbook2.xlsx”);

wb1.Combine(wb2);


wb1.Save(@“MergeOutError.xlsx”, SaveFormat.Xlsx);



Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.2.2.3 and let us know your feedback.

Appears to be fixed in this version. Thanks for the quick response!

Hi Dean,


It is good to know that you are up & running again. Please feel free to contact us back in case you need our further assistance with Aspose APIs.

Do you have any idea when this will be included in a production release ?


Thanks,
Dean

Hi Dean,


You can safely use the provided release in your production environment. However, if you would like to wait for the official release (Aspose.Cells for .NET 8.3.0), it will be published in the last quarter of November 2014 (or sooner). Please note, most of the major releases of Aspose API are published at the end of each month containing all the fixes reported during the period of one month.

The issues you have found earlier (filed as CELLSNET-43143) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.