toHTML method not applying fontsize

Posted by: ricardo.aleixo on 8 August 2023, 2:58 pm EST

  • Posted 8 August 2023, 2:58 pm EST - Updated 8 August 2023, 3:04 pm EST

    Hi.

    We’ve a table witch have font 8pt for exemple… then i set for all tabela 20pt, to force a big number, inside spread it’s ok. the size was respect.

    But after use toHTML methos, the words with underlined, they are not applying the font 20pt… continuing with 8pt for exemple… that was the old value.

  • Posted 9 August 2023, 5:11 am EST - Updated 9 August 2023, 5:16 am EST

    Hi,

    When exporting the Range to HTML, cell style such as font is also being exported to the HTML. If you have applied the font size to “20pt” then the exported HTML will have the fontsize 20pt.

    For example, refer to the following sample: https://jscodemine.grapecity.com/share/2rOz53a5306c9mxrNZuuog/?IsEmbed=false&Theme=Unset&PreviewDirection=0&IsEditorShow=true&IsExplorerShow=true&IsPreviewShow=true&IsConsoleShow=true&IsRunBTNShow=false&IsResetBTNShow=false&IsOpenInCodemineBTNShow=false&PanelWidth=20&PanelWidth=50&PanelWidth=30&defaultOpen={"OpenedFileName"%3A["%2Fapp.js"]%2C"ActiveFile"%3A"%2Fapp.js"}

    In the sample, cells in the Range B4:B8 have font size “20pt” and when you export the HTML and inspect the font size, you fill find the font size to be “20pt” in the exported HTML. This is the expected behavior as the font is exported.

    Please note that the SpreadJS is drawn on the canvas and it hides the overflown characters when the fontSize is large (same behavior as Microsoft Excel). However, in HTML, it will have to show the full text.

    You could also export the HTML without including the style by passing false as second parameter to the toHTML() method used for HTML export.

    Further, as per your use case, kindly reduce the fontSize before the exporting to HTML and then after the export, apply back the fontSize back to the cells to have the desired fontSize of HTML export.

    I hope this clarifies the issue you are facing. Please let me know if you have still face any issues.

    You could refer to the following docs on supported and unsupported features when exporting a range to the HTML: https://www.grapecity.com/spreadjs/docs/excelimpexp/export-range-to-html

    toHTML method: https://www.grapecity.com/spreadjs/api/v15/classes/GC.Spread.Sheets.CellRange#tohtml

    Regards,

    Ankit

  • Posted 14 August 2023, 12:45 pm EST

    Hii…

    about the size of font, that’s rigth… and about the overflow, we fixed…

    as i said on the quote, is about using (Underline) and change font.

    I use 20pix just for exemple… if you notice in the second pic, You’ll se that underline text isn’t applying the font.

  • Posted 16 August 2023, 3:37 am EST - Updated 16 August 2023, 3:42 am EST

    Hi,

    As per my understanding when you apply the textDecoration “underline” on a cell and then export to the HTML, the font is not being applied. Could you confirm if its the issue?

    I tested with the latest version of SpreadJS V16.1.4 and after applying the Underline on a cell and then exporting the HTML, the font and the underline both are being applied on the exported HTML.

    For example, you could refer to the following modified sample in which the underline is being applied to the Cell B4 and the font size is 20px. If you export the HTML and inspect the element, you will find that both the underline and the font is applied correctly. You could refer to the attached gif below.

    Sample: https://jscodemine.grapecity.com/share/miSxZ0m0yUqlYy6k6ViDIA/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fapp.js"]%2C"ActiveFile"%3A"%2Fapp.js"}

    If your issue differs from the mentioned one, kindly share us a sample along with a video describing the issue so that we could have a better understanding of your issue and could assist you accordingly.

    Regards,

    Ankit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels