Aspose cells read xlsm file with macros

Hello team,
I want to load a template xlsm file and read cells data with Visual Basic code function.

My code:
Worksheet worksheet = workbook.getWorksheets().get(model.getSheet());
com.aspose.cells.Cells cells = worksheet.getCells();
com.aspose.cells.Cell cell = cells.get(“H18”);
String value = cell.getStringValue();

But value return null. Is my code wrong?.(cell H18 data not null when open with Microsoft Excel)
Thanks for support!

image.png (23.8 KB)

@nguyentiep19901,
Thank you for your query. Please share the template Excel file which is used for testing at your end. We will run your sample code using the template file and share our feedback after detailed analysis.

@nguyentiep19901,

By the way, could you try to add a line to your code segment, if it makes any difference:
e.g
Sample code:


Worksheet worksheet = workbook.getWorksheets().get(model.getSheet());
workbook.calculateFormula();
com.aspose.cells.Cells cells = worksheet.getCells();
com.aspose.cells.Cell cell = cells.get(“H18”);
String value = cell.getStringValue();

If you still find the issue, as requested above, please zip your template Excel file and provide us, we will check it soon.

onversion. Document is broken after copying sheets. Issue with smart markers in merged cells. Exception “ClassCastException: …” when calculating PivotTable. New Workbook with CSV file results.

@Reeves,

Please provide your sample console application (runnable) with template files to show the issue, we will check it soon.

PS. please zip the files prior attaching.

This conversion was working fine for multiple sheets while using Aspose.Cells. However for single sheet workbook, there was no tab page and only HTML file was created without creating the separate folder containing CSS. Now Aspose.

@Franciesc,

See the following sample code (especially the line in bold) that I tested using my sample file for reference and try it, it would accomplish your desired task:
e.g
Sample code:

Workbook wb = new Workbook(“e:\test2\Bk_test1.xlsx”);

//Specify HtmlSaveOptions
HtmlSaveOptions opts = new HtmlSaveOptions();
opts.ExportSingleTab = true;

//Save the workbook in HTML format with above HtmlSaveOptions
wb.Save(“e:\test2\outBook12.html”, opts);

Please also, find attached the template file and output Html (with resource files).
files1.zip (6.3 KB)