SpreadsheetML to XHTML produces invalid HTML

Hi,

I hope you can help. I have a sample Visual Studio solution that demonstrates that a cells workbook that’s saved as XHTML produces HTML which has invalid nested ‘a’ tags, when a range has been named. I’ve debugged through, and although none of my names have spaces in them (Program.cs: line 39), simply setting this property causes a downstream issue, where the XHTML is invalid.

The code included is somewhat replicating what our code path is, so isn’t the most minimal steps.
Simply commenting out line 39 and then the XHTML save is better.

I believe we had this code in to replace spaces with empty to circumvent a bug we found that excel is fine with spaces in range names, but aspose wasn’t.

Roughly -
we generate some SpreadSheetML
we merge all sheets into one sheet using aspose api, and transpose ranges, and name them.
We resave this as XHTML using aspose - at this point the xhtml is already wrong.
We strip out some nasty MSO tags and fix other bugs.

AsposeExcelBug.zip (6.1 MB)

P.s. on my first attempts your upload system tells me that I can’t upload more than 48Mb, even though my file was only 14mb first time round.

@GMiddleton
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-56277

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.

1 Like

@GMiddleton ,

We are pleased to inform you that your issue has been resolved. The fix will be included in an upcoming release (Aspose.Cells v24.8) that we plan to release in the first half of August 2024. You will be notified when the next version is released.

Attached is the fixed result for your reference:
output.zip (3.9 KB)

You can use the following code to avoid outputting MSO stuff:

HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.XHtml);
saveOptions.ExportFrameScriptsAndProperties = false;
saveOptions.ExportWorkbookProperties = false;
saveOptions.ExportWorksheetProperties = false;
saveOptions.ExportDocumentProperties = false;
workbook.Save(msIntermediate, saveOptions);

Hope, this help a bit.

1 Like

That’s great news, thank you.
You guys are so quick at solving problems, makes the renewal of licences to get these updates worthwhile.
And thanks for the tips on auto-removing the MSO garbage :slight_smile:

@GMiddleton
Thank you for your feedback. You are welcome. If you have any questions, please feel free to contact us at any time. We will notify you promptly once the version v24.8 is released.

@GMiddleton ,

We will replace <br> with <br/> in the next version.
For &nbsp; , we will consider adding an option to indicate that whether &nbsp; should be replaced with &#160.
Please feel free to share any suggestions you may have. We would greatly appreciate your help.

1 Like

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

@GMiddleton ,

Please note that we have added HtmlSaveOptions.EncodeEntityAsCode in Aspose.Cells 24.8, which you can use to replace &nbsp; with &#160;.

Sample code:

  HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.XHtml);
  saveOptions.EncodeEntityAsCode = true;
  workbook.Save(msIntermediate, saveOptions);
1 Like