Hi Team,
Below is the HTML received from the database.
<h1>Heading 1</h1>
<p><strong>bold</strong></p>
<p>Align left</p>
<p class="ql-align-center"><br></p>
<p class="ql-align-center"><span style="background-color: rgba(255, 255, 255, 0.2);">Align center</span></p>
<p class="ql-align-center"><br></p>
<p class="ql-align-right">Align right</p>
<p class="ql-align-right"><br></p>
<p class="ql-align-justify">Justify</p>
<p class="ql-align-justify"><br></p>
<ul data-checked="true">
<li class="ql-align-justify">Checklist</li>
</ul>
<p class="ql-align-justify"><br></p>
<p class="ql-align-justify">Decrease</p>
<p class="ql-align-justify" style="padding-left: 3em;">Increase</p>
<p class="ql-align-justify"><span style="color: rgb(255, 153, 0);">Text color</span></p>
<p class="ql-align-justify"><span style="background-color: rgb(230, 0, 0); color: rgb(255, 153, 0);">Highlight</span></p>
<p class="ql-align-justify"><a href="https://www.google.com/" rel="noopener noreferrer" target="_blank">https://www.google.com/</a></p>
<p><br></p>
and using the below code to export the html string to excel
var cell = wsd.Cells[cellAddress];
cell.HtmlString = dtCloned.Rows[i][j].ToString();
But the Alignment, URL and Highlight not working also checklist is showing in bullet format.
can someone help me with the same, please?
asposecellerror2.PNG (3.4 KB)
Thanks in advance.
asposecellerror.PNG (51.6 KB)
asposecellerror2.PNG (3.37 KB)
@samadhansalgar,
Thanks for the screenshots.
There are some restrictions in MS Excel when parsing HTML strings to a cell. Please note the following, and you may also manually check/confirm in MS Excel:
-
In MS Excel, you cannot add a hyperlink for only a part of a cell’s text or string. The entire text will be hyperlinked or no hyperlink will be added. Therefore, the HtmlString attribute cannot be used to add hyperlinks to specific parts of the cell’s text.
-
In MS Excel, text highlighting cannot be set for a part of the text in a cell. Therefore, text highlighting would not work with Aspose.Cells.
Aspose.Cells adheres to MS Excel standards and specifications when parsing/rendering HTMLs. However, if you believe that you can achieve your desired formatting for a single cell in MS Excel manually (using MS Excel’s built-in formatting and other options), please create a sample Excel file with a cell containing your desired formatting (as per your HTML code) intact, save the Excel file, and provide it to us (please zip the file before attaching). We will review it promptly.
1 Like
@amjad.sahi - Thanks for the updates,
We will create sample console application and will share with you same.
@samadhansalgar
Thank you for your feedback. After receiving your sample file and console project, we will check it soon.
272623-AsposeCellHtmlHighlightIssue.zip (11.9 KB)
@amjad.sahi , @John.He - please find the attached project file.
please let me know still anything else required from my side.
thanks
@samadhansalgar,
Thanks for the project but we requested you (see my previous reply) to provide a sample Excel file containing your desired formatting for a single cell.
…if you believe that you can achieve your desired formatting for a single cell in MS Excel manually (using MS Excel’s built-in formatting and other options), please create a sample Excel file with a cell containing your desired formatting (as per your HTML code) intact, save the Excel file, and provide it to us (please zip the file before attaching). We will review it promptly.
Please note, if MS Excel cannot accomplish the task precisely, Aspose.Cells cannot do it as well.
Hi @amjad.sahi
We have a Vue.js web application, and we are using the third-party CKEditor for the rich text editor. We save the content into a database as a html string, and when retrieving it, we display it in the UI.
Screenshot 2023-10-20 190245.PNG.jpg (16.6 KB)
Now, we are attempting to export this content to an Excel file.
Please find the requested Excel file generated from the code above.
HTMLToExcel.zip (6.0 KB)
is it possible to do the samec format in the 1 cell of the sheet?
@samadhansalgar
We will evaluate it and feedback to you soon.
@samadhansalgar,
I think you are not getting me. I requested you to kindly provide an Excel file having a cell which contains the data in your desired formattings/styles. I do not think you could do your desired formatting in a single worksheet cell of MS Excel manually. The Excel file does not have your desired formatting for the cell. Please note, we think MS Excel does not support the following as I already told you:
- In MS Excel, you cannot add a hyperlink for only a part of a cell’s text or string. The entire text will be hyperlinked or no hyperlink will be added. Therefore, the HtmlString attribute cannot be used to add hyperlinks to specific parts of the cell’s text.
- In MS Excel, text highlighting cannot be set for a part of the text in a cell. Therefore, text highlighting would not work with Aspose.Cells.
I do not think all your desired formatting (as per your shred screenshot) could be implemented for a single cell in the worksheet in MS Excel. MS Excel has its own restrictions/limits, so when you render HTML to XLSX, you find certain things would not work as I told you earlier.
Maybe you could split formatted data (as per your screenshot) to be pasted in different cells instead of everything in a single cell. This way, you will use and set certain parts of data via Cell.HtmlString for different cells (in the same column). Alternatively, you may load the whole HTML file via Aspose.Cells.Workbook object and then try to render to XLSX if it makes some difference.
Hello @amjad.sahi - you can close this ticket, as we have restrictions for the desired formatting in one cell in Excel.
thank you
@samadhansalgar,
Alright, and it is nice to know that you understand it now. We have closed the ticket.