Doesn’t work:
titleCell.HtmlString = "Title "
Works fine:
titleCell.HtmlString = " Title"
Same, works fine:
titleCell.HtmlString = "Title Title2"
Aspose.Cells updated in october 2024
Doesn’t work:
titleCell.HtmlString = "Title "
Works fine:
titleCell.HtmlString = " Title"
Same, works fine:
titleCell.HtmlString = "Title Title2"
Aspose.Cells updated in october 2024
I tested your scenario/case using latest version/fix: Aspose.Cells 25.1.x (Releases | NuGet) and it works OK.
e.g.,
Sample code:
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
string value = "Test ";
worksheet.Cells[1,1].HtmlString = value;
value = " Test ";
worksheet.Cells[2,1].HtmlString = value;
value = " Test Test ";
worksheet.Cells[3,1].HtmlString = value;
value = " Test Test";
worksheet.Cells[4,1].HtmlString = value;
workbook.Save("e:\\test2\\out1.xlsx");
Please find attached the output Excel file for reference.
out1.zip (5.9 KB)
If you still find the issue with latest version/fix, let us know with details and sample files to reproduce the issue on our end and will look into your issue soon.
try this as title
var htmlTitle = "<div class='ui-title ui-property-title' style='text-align: left;'>SDgadshjf </div>"
titleCell.HtmlString = htmlTitle;
Thanks for the further details.
I am able to reproduce the issue as you mentioned by using your html string. I found that apparently I can’t set HTML title that ends with “space”, there is no space after the word.
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
string value = "<div class='ui-title ui-property-title' style='text-align: left;'>SDgadshjf </div>";
worksheet.Cells[1,1].HtmlString = value;
workbook.Save("e:\\test2\\out1.xlsx");
We require thorough evaluation of the issue. 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-57745
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.
We evaluated your issue in details.
If you write the same HTML string, i.e,"SDgadshjf " in an HTML file and then open it into the browser, you will see that there is no space after the word either. So, Aspose.Cells works the same way as the browser. You can use “ ” to display space:
"<div class='ui-title ui-property-title' style='text-align: left;'>SDgadshjf </div>";
Let us know if you still have any issue or confusion.
Ur example with “opening it in browser” gives me no sense how it should save me from .net error while building a document. I’m just asking you to handle it on your side. Setting a property and getting nullRef is wild and by my experience should be fixed on your side, not each customers side.
I simply want to convey that the problem does not lie with the Aspose.Cells APIs, but rather with how the browser handles the ending space by eliminating it. To verify this, I created a sample HTML file using your HTML string, saved it, and opened it in the browser (please see the attached sample HTML for your reference).
test1.zip (244 Bytes)
I noticed that the trailing space isn’t recognized (you can attempt to highlight the text and see that there is no trailing space) while examining/viewing it. We believe this is not a problem with Aspose.Cells and cannot be resolved within the API.
We investigated that problem again and want ask you to double check on current LTS version does that error produces on cases:
<div>asdgasdfg </div><div> sdgkadsfgadg</div>
<Font Style="FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #000000;VERTICAL-ALIGN: middle;"></Font>
<div style="text-align:left;vertical-align:top;padding-top:4px;padding-right:6px;padding-bottom:4px"><div><span style="color: rgb(0, 138, 0);">-3 </span></div></div>
Logic is similar\simple, just create a workbook and try to insert to a cell with call of InsertHtml(… .
Cause as u said above: “So, Aspose.Cells works the same way as the browser”, i found something related to html specification and exactly specifications related to spaces and there is only:
HTML parsing: According to HTML spec, leading/trailing spaces in text nodes are preserved by default
Whitespace collapsing : Multiple consecutive spaces are collapsed into one, but single spaces at start/end are kept
But there is nothing similar to that case
@bloodboilAaromatic
a.zip (410 Bytes)
We copied 3 nodes to a.html file. All spaces could not be visible in browser. It seems leading/trailing spaces in text nodes are not preserved by default.
We imported them with Cells.HtmlString using current latest version, all spaces are trimmed too.
HTML parsing: According to HTML spec, leading/trailing spaces in text nodes are preserved by default
Yes , the paser preserves leading/trailing whitespace in text nodes.
That means in the DOM you’ll still see:
document.querySelector('div').firstChild.nodeValue === "asdgasdfg "
So the space exists in the DOM.
When the browser lays out the text (using the CSS white-space property, defaulting to normal), it applies whitespace collapsing rules from CSS Text Module Level 3:
under the default white-space: normal,
it produces no visible gap at the end.
How to verify
Copy following to a.html file and open in browser:
<div >asdgasdfg </div>
No space is visible in browser
If you change to:
<div style="white-space: pre;">asdgasdfg </div>
— now you’ll see the extra space at the end.
@bloodboilAaromatic
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-59356 Spaces not preserved when setting Cell.HtmlString with style "white-space:pre" applied
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.
For now, that doesn’t really matter can see i them or not, what i’m highly interested that it can abort generation, like i need to parse document to remove spaces and after my parse u gonna do it again, tha t’s an issue
u opened a ticket cause u produced an error (Index outside of bounds)?
We logged a ticket with an id “CELLSNET-59356” into our database because we need to investigate on spaces were not preserved when setting Cell.HtmlString with style “white-space:pre” applied. Once we have an update on the issue, we will let you know here.
I tested with the following code and it worked OK:
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
string value = "<div>asdgasdfg </div>";
worksheet.Cells[1,1].HtmlString = value;
workbook.Save("e:\\out.xlsx")
To better understand why it abort generation (Index outside of bounds), could you please share your sample code or project that reproduces the issue? That will help us identify the cause more accurately.
Yeah, tested this scenario with provided test cases on LTS 25.11 (current was 24.10) and you fixed that in one of the versions…
Funny thing - u devs denied that problem in february of this year
got exception on font-size: auto, before there was no problem like that
<div style="font-weight:bold;font-size:auto;padding-top:4px;padding-right:6px;padding-bottom:4px"><div>Vulnerability rate</div></div>
got error:
{“The input string ‘’ was not in a correct format.”}
But that’s okay, i think that is new limitation rule
I cannot provide u a sample of code, cause we don’t have static document generation, there is more complicated document generation where users can create their own unique documents by html markup.
Thanks for the details.
I reproduced the issue as you mentioned by using the following sample code. I found an exception “'The input string '' was not in a correct format” when setting an HTML string “Vulnerability rate” to a worksheet cell.
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
string value = "<div style=\"font-weight:bold;font-size:auto;padding-top:4px;padding-right:6px;padding-bottom:4px\"><div>Vulnerability rate</div></div>";
worksheet.Cells[1,1].HtmlString = value;//exception
workbook.Save("e:\\test2\\out1.xlsx");
We require thorough evaluation of the issue. 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-59369
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.
We are pleased to inform you that your issue has been resolved. The fix will be included in an upcoming release (Aspose.Cells v25.12) that we plan to release in the first half of December 2025. You will be notified when the next version is released.
The result after applying the fix is attached for your review:
output.zip (5.9 KB)