Free Support Forum - aspose.com

Font size difference when converting Excel files to HTML with Aspose.Cells for Java

Hi, i’m using trial now and i’m considering to purchase.
but just wondering, wehn i convert excel to html, few font size were changed.
you can see through the pic on blue color.

excel.png (75.7 KB)
html.png (45.0 KB)

what can i do with this?

@sora,
Please share your sample file and code snippet with us for our testing. We will reproduce the problem and provide our feedback after analysis.

20191205452.zip (36.5 KB)

only zip file is authorized!
here is my file =) thanks for your reply!

@sora,
I have tried to reproduce the issue but could not succeed. The sample Excel file is converted to HTML using Aspose.Cells and MS Excel both, but no difference in font size is observed. Could you please share more details about this issue? How are you comparing the font size and is the required font installed on your system which is used in the Excel file. Please ensure that the respective font is installed and latest version of Aspose.Cells is used for testing the issue.
output.zip (41.7 KB)

Thanks for your efforts.
well i haven’t purchase yet, so i’m using trial version.
i wanted to purchase after i try trial version if it suit for me. almost everything is okay to convert, but only this one is the problem.

the code i’m using is
com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(fis); com.aspose.cells.HtmlSaveOptions saveOptions = new com.aspose.cells.HtmlSaveOptions(com.aspose.cells.SaveFormat.HTML); wb.save("html.html", saveOptions);

and the font is default font which is always installed originally.
maybe is it about trail version issue?

that is the only detail i can give more =( sorry =(
i did same things on other excel files but they were fine

@sora,
Well, trial version does not impose such type of limitation where fonts are not rendered properly. It seems that the Excel files which are working fine are compatible in terms of fonts installed on the system. This difference in font may occur if required font is not installed. Please add the required fonts (with all sizes) to the system and set the font directory using CellsHelper.setFontDir method.
You may follow the following articles to get an idea about handing fonts while rendering the spreadsheets. Please give it a try and share the feedback.

Set Default Font while rendering spreadsheet to HTML
Configuring Fonts for Rendering Spreadsheets
Set Default Font while rendering spreadsheet to images

If it does not fulfil your requirement, please try to implement the font substitution warning to check if this issue is due to font unavailability or not.

// assumes the Workbook is in the classpath

Workbook wb = new Workbook("Sample.xlsx");
wb.getWorksheets().setActiveSheetIndex(0);

// export the worksheet
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML);
// use UTF-8 encoding
options.setEncoding(Encoding.getUTF8());
options.setHtmlCrossStringType(HtmlCrossType.DEFAULT);
options.setPresentationPreference(true);
options.setExportActiveWorksheetOnly(true);
options.setExportImagesAsBase64(true);

// implement anonymous callback class

      IWarningCallback callback = new IWarningCallback() {
       @Override
       public void warning(WarningInfo info) {
          System.out.println(info.getDescription());
       }
      };
      options.setWarningCallback(callback);

// save HTML file to current folder

  File file = new File("ColumnWidthsBug_" +
                       System.getProperty("os.name").replace(' ', '_') + 
                       ".html");
 try (FileOutputStream out = new FileOutputStream(file)) {
   wb.save(out, options);
 }
  if (file.exists()) {
    System.out.println("Successfully generated HTML file: " + 
                        file.getAbsolutePath());
 }

thanks for your reply!!
i will try and let you know

@sora,
You are welcome.
Let us know your feedback.