Aspose.Cells..PutValue() and HTML content - any way that I can put HTML content in with PutValue?

Hi there, I’m using Aspose.Cells 4.8.1.7. I’m trying to put HTML content into particular cells. Or rather formatted content. Some background, my client would like to be able to post formatted content into Excel cells.

Your API has a great feature that lets you retrieve cell content as formatted content. It returns it styled with inline HTML styling. That’s great. That’s the Cell.HtmlString property.

But what I would love to be able to do is then do the reverse - take the same Cell.HtmlString, or some other arbitrary HTML string, and plop it back into Excel.

See attachments for details. Do you think this would be feasible for you to implement anytime soon?

Thanks
Shan

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Well, your requested feature is not supported at the moment. We have already registered this feature in our internal issue tracking system for implementation in future with issue id CELLSNET-6868. As it is a complex feature, so it may not be implemented / released soon. You may try to use the cell.Characters API to format the cell data. Please see the following sample code in this regard:

//Instantiating an Workbook object

Workbook workbook = new Workbook();

//Obtaining the reference of the newly added worksheet by passing its sheet index

Worksheet worksheet = workbook.Worksheets[0];

//Accessing the "A1" cell from the worksheet

Aspose.Cells.Cell cell = worksheet.Cells["A1"];

//Adding some value to the "A1" cell

cell.PutValue("Rich Text Formatting Demo");

cell.Characters(3, 15).Font.IsItalic = true;

cell.Characters(5, 4).Font.Name = "Algerian";

cell.Characters(21, 4).Font.Color = Color.Red;

//Saving the Excel file

workbook.Save("C:\\testing123.xls");

Thank You & Best Regards,

Thanks Nausherwan, have others requested this type of feature before? If so or not, what do you think would realistically be your timing for incorporating this feature into your library?

Thanks
Shan

Hi Shan,

Yes, some other users also demanded this feature before. The feature is included in our work list document.

We will analyze and check if we can provide you an eta for the feature.

Thank you.

Hi,

<span style=“font-size: 11pt; font-family: “Calibri”,“sans-serif”; color: rgb(31, 73, 125);”>Please try the attached fix. We have supported to set html string value as the cell value. Kindly try the version.


Here is sample line of code.
<span style=“font-size: 11pt; font-family: “Calibri”,“sans-serif”; color: rgb(31, 73, 125);”> <o:p></o:p>

cells["A1"].HtmlString = cells["B2"].HtmlString;


Thank you.

Amjad I just tried out, it works in the sense that it now inserts content into the cell as HTML, but it doesn’t seem to preserve the formatting of the text, such as colours, underlines, etc.

I.e. if I paste this in:
[ONLY USE IF SIGNIFICANT CHANGE HAS OCCURRED; OTHERWISE, DELETE CONTENTS OF CELL] The decline/increase in passenger traffic shown by the most recent year-to-date data can be attributed in large part to … [SF/NY offices add:] As of Month 20XX, this airport facility was served by XX airlines, offering daily flights to XX destinations; at the same time last year, the facility was served by XX airlines and offered XX flights daily.


Export the test Excel and open, the cell contains the text but not formatting. If I save in .xlsx format, and open, I see this Office XML which looks like just the font name and size are brought in, which dont’ quite appear to be correct:











[ONLY USE IF SIGNIFICANT CHANGE HAS OCCURRED; OTHERWISE,









DELETE








CONTENTS OF CELL]










The decline/increase in passenger traffic shown by the most recent year-to-date data can be attributed in large part to …









[SF/NY offices add:]










As of Month 20XX, this airport facility was served by XX airlines, offering daily flights to XX destinations; at the same time last year, the facility was served by XX airlines and offered XX flights daily.



Hi,

Thanks for your feedback,

We will look into it and get back to you soon.

Thank you.

Hi,

We will fix it soon. We will inform you when it is sorted out.

Thank you.

Hi,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells. We have fixed your mentioned issue.

Thank You & Best Regards,

So far what I’m seeing looks great. The content seemed to be inserted with a high level of accuracy with some initial tests.

Thx!
Shan

Hi,
I am in need of embedding html content in cells and have tried the 4.8.2.6 version of the dll. I find that though some colors and fonts work, some common html tags such as
don’t quite work as expected. Could you please tell me what level of html support (i.e. html versions) does ASPOSE intends to provide in the Cells component?

Thanks,
lama

Hi,

We support
and other html attributes e.g, ,,,,,,
For your requirement, we will support


We have logged it into our issue tracking system with an issue id: CELLSNET-14885.

Thank you.

Hi,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please try the attached latest version of Aspose.Cells. We have supported
as per your requirement.

Thank You & Best Regards,

Hi,

I used the latest attachment here as I have a similar requirement.
However, the html content that I am trying to export to excel is something like this:



Is this supported?

Thanks,
Vid

Hi,

I think you may try:

cell.HtmlString = “<font style=“font-weight: bold; color: #0066cc; background-color: #99cc00”>2324”;


Thank you.

Hi,

Thanks for the quick reply!

I know that changing the HTML content will enable it to render in the correct way.
However, our data has been stored in the database with this formatting style (using with styles). Will you be able to support it? Conversion of large quantities the html text that users have saved already using Rich text editors may not be possible to achieve the desired result.


Hi,

OK, we will support tag in Html parsing for your requirement. Your request has been logged into our issue tracking system with an issue id: CELLSNET-15405.

We will inform you when it is supported.

Thank you.

Hi,

Please try the attached version.

We have supported the span tag.

If you still have any problem, please feel free to contact us and we can check it soon.




Thank you.

It works very well indeed!
I appreciate your quick response and resolution.

Thanks much!