Combining Worksheets Resets Table Names

Hi,

Please can you help with an issue I am having regarding combining workbooks.

I have specified table names in the workbooks that I want to combine.

When I perform a Workbook1.Combine(Workbook2) command, the resulting merged document has reset the table names for the second workbook. Although the first workbook’s table names are intact.

is there a bug with this function, or is there a way to avoid the table names resetting?

Here is my code:


public static void TestMergeFiles(byte[] bArray1, byte[] bArray2)
{
//Instantiate the License class
Aspose.Cells.License licenseCells = new Aspose.Cells.License();
//Pass only the name of the license file embedded in the assembly
licenseCells.SetLicense(“Aspose.Total.lic”);

string filePath = Path.GetTempFileName() + “.xlsx”;
if ((bArray1 != null) && (bArray2 != null))
{
Workbook masterWorkbook = new Workbook(new MemoryStream(bArray1));
Workbook secondWorkbook = new Workbook(new MemoryStream(bArray2));
masterWorkbook.Combine(secondWorkbook);
masterWorkbook.Save(filePath);
}
}

I am passing the files as byte arrays from a FileUpload control’s FileBytes property…

Many thanks,

Dan

Also to add, I have tried opening the workbooks straight from their filepaths and also moving the worksheets across one by one, but I get the same result:


public static void TestMergeFiles(string filePath1, string filePath2)
{
//Instantiate the License class
Aspose.Cells.License licenseCells = new Aspose.Cells.License();
//Pass only the name of the license file embedded in the assembly
licenseCells.SetLicense(“Aspose.Total.lic”);

string filePath = Path.GetTempFileName() + “.xlsx”;

Workbook masterWorkbook = new Workbook(filePath1);
Workbook secondWorkbook = new Workbook(filePath2);

WorksheetCollection wksheets2 = secondWorkbook.Worksheets;

foreach (Worksheet wks in wksheets2)
{
masterWorkbook.Worksheets.Add();
int wksIndex = masterWorkbook.Worksheets.Count - 1;
masterWorkbook.Worksheets[wksIndex].Copy(wks);
}

masterWorkbook.Save(filePath);
}

Hi,



Please download and try this fix: Aspose.Cells for .NET v7.4.2.3

I have tested using the following code segments with it using your attached template files, the tables are rendered fine I think. Could you try it and let us know the results.

Sample code:

/*
Workbook masterWorkbook = new Workbook(“e:\test2\Workbook1.xlsx”);
Workbook secondWorkbook = new Workbook(“e:\test2\Workbook2.xlsx”);
masterWorkbook.Combine(secondWorkbook);
masterWorkbook.Save(“e:\test2\outputbook.xlsx”);
*/

string filePath = “e:\test2\newcombinedxlsx.xlsx”;

Workbook masterWorkbook = new Workbook(“e:\test2\Workbook1.xlsx”);
Workbook secondWorkbook = new Workbook(“e:\test2\Workbook2.xlsx”);

WorksheetCollection wksheets2 = secondWorkbook.Worksheets;

foreach (Worksheet wks in wksheets2)
{
masterWorkbook.Worksheets.Add();
int wksIndex = masterWorkbook.Worksheets.Count - 1;
masterWorkbook.Worksheets[wksIndex].Copy(wks);
}

masterWorkbook.Save(filePath);

I am unable to use the new dll because my subscription only allows older versions.

Thanks for your assistance anyway.

Cheers,
Dan

Hi,


We are sorry that your subscription expired and you cannot use our latest version/fix unless you upgrade your subscription. But, I think you may just try to check it, you may comment out your licensing code and try the new version/fix if it resolves the issue.

Thank you.

Hi,

I have recently purchased a new licence and retried your suggested code with the latest version of Aspose Cells.

Unfortunately, this error still remains.

The master workbook holds its table name ok, but the table in the worksheets copied across, revert to “table2”.

Please see attached file.

Can you advise how to accomplish this please?

Many Thanks,
Dan

Hi Dan,


Thanks for the template file.

I observed the issue using your original template files as you mentioned. The reason might be as both Workbooks have Table/List objects in “Sheet1” sheet, so when we merge Excel files, Aspose.Cells changes the sheet name of “Sheet1” in the Workbook2 to default name (e.g “Sheet5” as there is already “Sheet1” in the Workbook1) and sets the table name to “Table2” automatically. We will investigate and look into it if we could sort it out accordingly soon and we should not change the Table name even if we have to change the Worksheet’s name. I have logged a ticket with an id “CELLSNET-42273” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

Hi Dan,

Thanks for using Aspose.Cells.

We have fixed this issue.

Please download and try the fix: Aspose.Cells
for .NET v7.7.0.4
and let us know your feedback.

Hi,

Yes thanks that fixes the issue with resetting table names.

However, I have found another problem:

When there is a table referenced in a formula, it corrupts the sheet.

Please find attached amended files…
In particular, see the formula in column G that causes the bug.

Many Thanks,
Dan

Hi,


I could not find the issue. I used the following sample code with your attached files using latest fix… I have also attached the output merged file for your reference. I have opened the file into MS Excel 2007/ 2010 and checked the named ranges and the table’s formulas on G column, they are retained as they are in the template file.
e.g
Sample code:

Workbook masterWorkbook = new Workbook(“e:\test2\Workbook1.xlsx”);
Workbook secondWorkbook = new Workbook(“e:\test2\Workbook2.xlsx”);
masterWorkbook.Combine(secondWorkbook);
masterWorkbook.Save(“e:\test2\outmerged1.xlsx”);


Could you give us details, how it corrupts the sheet, you may attach some screen shots comparing the formulas etc., we will check it soon.

Thank you.




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


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

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan