Workbooks which have an “Excel 4 Macro Sheet” and/or a “Dialog Sheet” are coerced into regular worksheets when opened and/or saved by Aspose Cells.
This issue can be observed by using the attached InvalidSheets.xlsm Workbook and the following Java code:
final String fileName = "[path]InvalidSheets.xlsm";
Workbook wb = new Workbook(fileName);
for(Iterator<Worksheet> i = wb.getWorksheets().iterator(); i.hasNext();) {
Worksheet ws = i.next();
System.out.println("Sheet Name: " + ws.getName() + " Type: " + ws.getType());
}
wb.save(fileName.replace(".xlsm", "_aspose.xlsm"));
Notes:
- The attached workbook contains 2 sheets - an Excel 4 Macro" Sheet and a Dialog Sheet.
- The console output shows that when the Workbook is loaded, it interprets the macro and dialog sheets as regular Worksheets (i.e.
ws.getType() == SheetType.Worksheet
).
- We are expecting that the sheet types be SheetType.BIFF_4_MACRO and SheetType.OTHER.
- We need to detect the Macro and Dialog sheets while converting a Workbook to PDF. But based on the current functionality, we are not be able to detect these types of sheets.
- The above was reproduced using the latest version of Aspose Cells 18.1.
Thanks.
@oraspose,
Thanks for the template file, sample code and details.
After an initial test, I am able to observe the issue as you mentioned by using your sample code with your template file. I found that Macro and Dialog sheets are detected as regular worksheets:
e.g
Sample code:
final String fileName = "[path]InvalidSheets.xlsm";
Workbook wb = new Workbook(fileName);
for(Iterator<Worksheet> i = wb.getWorksheets().iterator(); i.hasNext();) {
Worksheet ws = i.next();
System.out.println("Sheet Name: " + ws.getName() + " Type: " + ws.getType());
}
wb.save(fileName.replace(".xlsm", "_aspose.xlsm"));
Output:
Sheet Name: Macro1 Type: 1
Sheet Name: Dialog1 Type: 1
I have logged a ticket for your issue and we will try to figure it out soon. The issue is logged as following:
CELLSJAVA-42507 - Macro and Dialog Sheets are detected as regular worksheets
Once we have an update on it, we will let you know here.
@oraspose,
This is to inform you that we have fixed your issue CELLSJAVA-42507 now. We will soon provide the fix after performing QA and including other enhancements and fixes.
@oraspose
Please download and try the following fix and let us know your feedback
The issues you have found earlier (filed as CELLSJAVA-42507) have been fixed in this Aspose.Cells for Java 18.2 update.
Please also check the following document/blog for your reference: