Copy worksheet error

Hi. I have a report, that should include another reports within. So i copy worksheets from source reports to one target. But since version 8.7.1 i got error:


com.aspose.cells.Name cannot be cast to java.lang.Integercom.aspose.cells.Name cannot be cast to java.lang.Integercom.aspose.cells.Name cannot be cast to java.lang.Integer

There is test case:

public static String preventSheetNamesDuplicates(Workbook target, Workbook source, int iCount) {
String sheetName = source.getWorksheets().get(iCount).getName();

int sheenAddNum = 1;
String newSheetName = sheetName;
while (target.getWorksheets().get(newSheetName) != null) {
newSheetName = sheetName + “_” + sheenAddNum;
sheenAddNum++;
}

source.getWorksheets().get(iCount).setName(newSheetName);
return newSheetName;
}

public void copyBook(Workbook target, Workbook source) {
for (int iCount = 0; iCount < source.getWorksheets().getCount(); iCount++) {
//Формируем имя листа, если такой лист уже есть, то переименовываем
String newSheetName = preventSheetNamesDuplicates(target, source, iCount);
target.getWorksheets().add(newSheetName);
}

for (int iCount = 0; iCount < source.getWorksheets().getCount(); iCount++) {
Worksheet sourceWs = source.getWorksheets().get(iCount);
Worksheet targetWs = target.getWorksheets().get(sourceWs.getName());
try {
targetWs.copy(sourceWs);
targetWs.getPageSetup().setPrintArea(sourceWs.getPageSetup().getPrintArea());
} catch (Exception e) {
System.err.print(e.getMessage());
}
}

}

@Test
public void copyBookTest() throws Exception {
Workbook target = new Workbook(“D://target.xls”);
copyBook(target, new Workbook(“D://source.xls”));
copyBook(target, new Workbook(“D://source1.xls”));
copyBook(target, new Workbook(“D://source2.xls”));
copyBook(target, new Workbook(“D://source3.xls”));
}

Best regards. Alexey

Hi Alexey,


Thank you for providing the samples and code snippet.

We have evaluated the presented scenario while using the latest revision of Aspose.Cells for Java 8.7.1.2 and we are able to replicate the said exception (com.aspose.cells.Name cannot be cast to java.lang.Integer) on our side. In order to thoroughly investigate the matter, could you please provide the version of Aspose.Cells for Java that worked well for this scenario?

Hi. So previous version, that works correctly is 8.6.3


Best regards. Alexey

Hi Alexey,


Thank you for your response. We have logged this incident as CELLSJAVA-41768 in our bug tracking system for further investigation. Please spare us little time to thoroughly analyze the scenario and get back with updates in this regard.

Hi again,


This is to update you that we have resolved the problem logged earlier as CELLSJAVA-41768. We will shortly share the fix here after ensuring the quality and incorporating other enhancements.

Hi Alexey,


Please try the latest version of Aspose.Cells for Java 8.7.1.4 against the problem logged earlier as CELLSJAVA-41768. I have tested the scenario using aforementioned revision of the API and I am no longer able to replicate the said exception.

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


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