Wrong HTML format conversion

Hi, we are saving a workbook as html with this code:

var wb = new Workbook("Excel1.xlsx");
using (var stream = new MemoryStream(1))
{
    var opts = new HtmlSaveOptions
    {
        ExportActiveWorksheetOnly = true
    };
    wb.Save(stream, opts);
    byte[] arr = stream.ToArray();
    var html = Encoding.UTF8.GetString(arr);
    File.WriteAllText("Html1.html", html);
}

And we have encountered the following formatting issues:

  • In the Excel1.xlsx workbook the negative numbers format is like -120, but in the html output it appears as (120)
  • In the Excel2.xlsx workbook positive numbers have a formatting space on the right, which is missing in the html output

Is there a way to fix these formatting issues in the html conversion?

Attachments.zip (810.2 KB)

@davidepedrocca,

Thanks for the template files and sample code.

When I open your input file into MS Excel, it is same as the output HTML file (shown in the browser), so it is not an issue with the APIs. See the attached image for your reference:
sc_shot1.png (56.8 KB)

I am able to reproduce the issue as you mentioned by using your sample code and template file. I found when converting the Excel file to HTML, some positive numbers’ formatting space (on the right) is missing in the output. I have logged a ticket with an id “CELLSNET-47501” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

Thank you for your reply.

For our first issue, we see the negative numbers with the minus sign.

Maybe you have the “Negative Number in Brackets across entire computer (including Excel)” option enabled in your computer, as it is explained in the following article: https://www.auditexcel.co.za/blog/excel-negative-numbers-in-brackets/

Could you please verify by changing this settings?

This is what we see:
image.png (17.4 KB)

@davidepedrocca,

I tried to access the article but got an error “Your access to this site has been limited by the site owner”.

By the way, what is your locale/regional settings?

I am attaching the article in pdf format and a screenshot of my regional settings.

Attachments.zip (303.3 KB)

@davidepedrocca,

Thanks for the screenshot and sample document.

After an initial test, I am able to reproduce the issue as you mentioned by using the sample code and template file. I first changed the regional settings to United Kingdom and checked your template file by opening into MS Excel and found the negative numbers are changed to e.g “-120” from “(120)”. I then tried the following sample code but the output HTML file is not expected. I even tried to set the locale settings and region in code accordingly but to no avail:
e.g
Sample code:

LoadOptions options = new LoadOptions(LoadFormat.Xlsx);
            options.Region = CountryCode.UnitedKingdom;
            var wb = new Workbook("e:\\test2\\Excel1.xlsx", options);
            wb.Settings.Region = CountryCode.UnitedKingdom;
            wb.Settings.LanguageCode = CountryCode.UnitedKingdom;
            using (var stream = new MemoryStream(1))
            {
                var opts = new HtmlSaveOptions
                {
                    ExportActiveWorksheetOnly = true
                };
                wb.Save(stream, opts);
                byte[] arr = stream.ToArray();
                var html = Encoding.UTF8.GetString(arr);
                File.WriteAllText("e:\\test2\\Html12.html", html);
            }

I have logged a ticket with an id “CELLSNET-47504” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@davidepedrocca,

This is to inform you that we have fixed your issue “CELLSNET-47504” now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@davidepedrocca,

Please try our latest version/fix: Aspose.Cells for .NET v20.7.2 (attached)
Aspose.Cells20.7.2 For .Net2_AuthenticodeSigned.Zip (5.4 MB)
Aspose.Cells20.7.2 For .Net4.0.Zip (5.4 MB)

Your issue “CELLSNET-47504” should be fixed in it.

Let us know your feedback.

@davidepedrocca,

Please try our latest version/fix: Aspose.Cells for .NET v20.7.6 (attached)

Your issue “CELLSNET-47501” should be fixed in it.

Let us know your feedback.
Aspose.Cells20.7.6 For .Net2_AuthenticodeSigned.Zip (5.4 MB)
Aspose.Cells20.7.6 For .Net4.0.Zip (5.4 MB)

Hi, we tried the latest fix and the issue seems to be resolved. Thanks

@davidepedrocca,

Thanks for your feedback.

We are happy that your issue is resolved by the new fix. Feel free to write us back if you have further queries or questions.

The issues you have found earlier (filed as CELLSNET-47501,CELLSNET-47504) have been fixed in Aspose.Cells for .NET v20.8. This message was posted using Bugs notification tool by Amjad_Sahi