We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error while combining several Excel files which has at least one worksheet with name containing �!�

We are getting error –“error in set print area” when trying to combine several excel files. First of the files has tab (worksheet) with name - “!”. The second file has tab with name - "Second sheet name". Our program copies tab from the second file into the first file and we are getting error. Both files have PrintTitleRows property.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We use:

- .Net 4.0

- Aspose library (please see attached file)

- Program example (please see attached file)

Can you please point us into the correct solution how to combine such kind of files? Is it a bug which doesn’t allow us to combine the files?

Hi,

I can find the issue as the user has mentioned by using his sample code with v7.1.0.x (latest fix).
I have logged a ticket with an id: CELLSNET-40334. We will look into your issue soon.

Sample code (Tested):

string sheetName1 = "!";
string sheetName2 = "Second sheet name";

string fileName1 = "e:\\test2\\File1_";
string fileName2 = "e:\\test2\\File2_";
string fileName3 = "e:\\test2\\ResultCombain_";

String time = DateTime.Now.ToString("yyyy-MM-dd_hh_mm_ss_tt");

//Create file 1
CreateFile(time, fileName1, sheetName1);

//Create file 2
CreateFile(time, fileName2, sheetName2);

//Create result, added in file 1 new sheet from second file
Workbook combainWorkbookFile = new Workbook(string.Format("{0}{1}.xlsx", fileName1, time));

Workbook workbookFile = new Workbook(string.Format("{0}{1}.xlsx", fileName2, time));
Worksheet newWs = combainWorkbookFile.Worksheets[combainWorkbookFile.Worksheets.Add()];
newWs.Copy(workbookFile.Worksheets[0]);
newWs.Name = workbookFile.Worksheets[0].Name;

combainWorkbookFile.Save(string.Format("{0}{1}.xlsx", fileName3, time),new OoxmlSaveOptions(SaveFormat.Xlsx));


private void CreateFile(string time, string fileName, string sheetName)
{
Workbook workbookFile = new Workbook();
Worksheet worksheet = workbookFile.Worksheets[0];
worksheet.Name = sheetName;
worksheet.Cells[0, 0].PutValue(sheetName);
SetPageHeaderRows(worksheet, 1);
workbookFile.Save(string.Format("{0}{1}.xlsx", fileName, time), new OoxmlSaveOptions(SaveFormat.Xlsx));
}

public void SetPageHeaderRows(Worksheet ws, int firstRow)
{
int lastRow = 0;
ws.PageSetup.PrintTitleRows = string.Format("${0}:${1}", firstRow, lastRow > firstRow ? lastRow : firstRow);
}


Thank you.

Hi,

Please download and try this fix:
Aspose.Cells for .NET (Latest Version).

Thank you,

We tried new library and it works properly.

Thank you very much for the quick response.

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.