Export Range as Html with Links Changes Styles

Hi there,

We are using Aspose.Cells Version=“23.4.0” in our dotnet 7.0 project.
We would like to export a range of cells as an html with links to make out html interactive.
Nevertheless, we don’t want our cell styles to change.
For some reason, when adding a link to a cell it changes its style, despite the fact that we are setting its previous style (saving style before adding the cell name to worksheet’s hyperlinks and setting saved style afterwards).
Attached are input.xlsx and output.html in a zip file and a code snipped of exporting the xlsx file to an html file.

links-html-style-issue.zip (319.9 KB)

Here is the code snipped:
public static class AsposeHelper
{
private static HtmlSaveOptions _htmlSaveOptions =>
new()
{
ExportImagesAsBase64 = true,
ExportPrintAreaOnly = true,
ExportHiddenWorksheet = false,
ExcludeUnusedStyles = true,
ExportActiveWorksheetOnly = true,
Encoding = Encoding.UTF8
};

        public static void ExportHtml()
        {
            Workbook wbc = null;
            using (FileStream ms = new FileStream(@"C:\demo-projects\aspose-html\input.xlsx", FileMode.Open))
            {
                wbc = new Workbook(ms, new LoadOptions(LoadFormat.Xlsx));
            }
            //DR_PUBv2__1661694548
            var range = wbc.Worksheets.Names["DR_PUBv2__1661694548"].GetRange();
            range.Worksheet.PageSetup.PrintArea = range.Address;
            wbc.Worksheets.ActiveSheetIndex = range.Worksheet.Index;

            foreach (Cell cell in range)
            {
                if (!cell.IsFormula)
                    continue;

                var links = range.Worksheet.Hyperlinks;
                var styleSet = $"javascript:void(0);_DRXX$33_{cell.Name}";
                var style = cell.GetStyle();
                links.Add(cell.Name, 1, 1, styleSet);
                cell.SetStyle(style);
            }
           

            using var html = new MemoryStream();
            wbc.Save(html, _htmlSaveOptions);
            File.WriteAllBytes(@"C:\demo-projects\aspose-html\output.html", html.ToArray());
        }
    }

@shlomi.z,

Thanks for the template Excel file.

We reproduced the issue as you mentioned by using your template Excel file. We found when exporting range as HTML with links, it changes styles/formatting somehow. For example, bold and alignment settings are changed a bit.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-53206

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@shlomi.z,

  1. The cell font in your template Excel file is Ariel, please confirm if it should be Arial.
  2. Please open the html files in the attachmenttest.zip (9.2 KB)
    in your browser to see if they display correctly.

Hi Eric,

  1. Cell font is Ariel.
  2. The upper left cell (operand 1) seems off :
    image.png (2.2 KB)

@shlomi.z,

Thanks for the details and screenshot.

We have logged with your existing ticket into our database. We will evaluate and get back to you soon.

@shlomi.z,

This is to inform you that your issue has been resolved. The fix will be included in an upcoming release (Aspose.Cells v23.5 that we plan to release in the first half of May 2023. You will be notified when the next version is released.
Here is the result file generated after fix: output.zip (4.6 KB)

The issues you have found earlier (filed as CELLSNET-53206) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi

Hi there,

I’ve upgraded to the latest version (23.5.0) and it seems that there’s a regression.
Attached is the input.xlsx and output.html in a zip file:
link-html-style-issues-23.5.0.zip (319.7 KB)

This is the code snipped:
public static class AsposeHelper
{
private static HtmlSaveOptions _htmlSaveOptions =>
new()
{
ExportImagesAsBase64 = true,
ExportPrintAreaOnly = true,
ExportHiddenWorksheet = false,
ExcludeUnusedStyles = true,
ExportActiveWorksheetOnly = true,
Encoding = Encoding.UTF8
};

    public static void ExportHtml()
    {
        Workbook wbc = null;
        using (FileStream ms = new FileStream(@"C:\demo-projects\aspose-html\input.xlsx", FileMode.Open))
        {
            wbc = new Workbook(ms, new LoadOptions(LoadFormat.Xlsx));
        }
        //DR_PUBv2__1661694548
        var range = wbc.Worksheets.Names["DR_PUBv2__1661694548"].GetRange();
        range.Worksheet.PageSetup.PrintArea = range.Address;
        wbc.Worksheets.ActiveSheetIndex = range.Worksheet.Index;

        foreach (Cell cell in range)
        {
            if (!cell.IsFormula)
                continue;

            var links = range.Worksheet.Hyperlinks;
            var styleSet = $"javascript:void(0);_DRXX$33_{cell.Name}";
            var style = cell.GetStyle();
            links.Add(cell.Name, 1, 1, styleSet);
            cell.SetStyle(style);
        }
       

        using var html = new MemoryStream();
        wbc.Save(html, _htmlSaveOptions);
        File.WriteAllBytes(@"C:\demo-projects\aspose-html\output.html", html.ToArray());
    }
}

Please advise.

Thanks,

Shlomi

@shlomi.z
Please confirm that “Ariel” font has installed correctly.Can you share us “Ariel” font ?
Which OS ,Net version and region setting are you using?