Show formula strings when saving Excel file to HTML in Java

Hello,

I’m opening a Workbook and then saving it into output stream in HTML format to be shown in browser. It works correctly, but when it comes to formulas, then those are calculated and the result is shown instead of showing the formula itself.

For example I have sheet with two numbers and then formula:
1 2 =A1+A2

What is saved to output stream is:
1 2 3

What I need is:
1 2 =A1+A2

I looked at the API:

  • com.aspose.cells.PdfSaveOptions#setCalculateFormula
  • com.aspose.cells.HtmlSaveOptions does not have such method

Is there an option to have formulas themselves in cells when saving in HTML format?

Code excerpt:

				    Workbook wb = new Workbook(content);
					HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.HTML);
					saveOptions.setExportActiveWorksheetOnly(true);
					saveOptions.setExpImageToTempDir(false);
					saveOptions.setExportImagesAsBase64(true);
					wb.getWorksheets().setActiveSheetIndex(sheetNumber);
					wb.save(outputStream, saveOptions);

@andrejj,

Thanks for providing us some details.

Aspose.Cells works the same way as MS Excel does when reading or writing HTML files. How could you accomplish the task in MS Excel manually? I simply created a workbook having a few formulas and then save to “Web Page” to generate an HTML file. In the output file I noticed the formulas are replaced with calculated values/results. So, this is not possible in MS Excel. I am afraid, if something is not possible in MS Excel manually, Aspose.Cells cannot do it either. If you can perform the task in MS Excel manually, kindly share sample files and provide details/steps involved, we will check it on how to do it via Aspose.Cells APIs.