Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Excel interpret a cell as HTML?

I'm using Aspose.Cells to build an Excel document programmatically. This works great. One of the cells, though, is a block of raw HTML. I'm wondering if it is possible to tell Excel (in any fashion, including the GUI - you don't need to know the Aspose API) to parse and display a cell as HTML. Right now, it just shows up as the raw HTML in text format, tags and all.

I know Excel is capable of having HTML pasted into it, but it looks like it just parses it on its own and then Excel-ifies it for you, and it doesn't store the HTML, so it's not actually parsing it and displaying it as HTML. Plus, I can't figure out how to replicate this paste functionality anyway.

Thanks.

like image 693
Greg Smalter Avatar asked Sep 07 '25 08:09

Greg Smalter


2 Answers

Unfortunately the answer is no.

Excel has two HTML options:

  • Open a HTML file, which will sort of render the HTML, sort of, but won't contain any actual HTML in cells
  • Store HTML in cells, but as unformatted text.

You could, maybe possibly, come up with a macro that lets you enter HTML into a cell, then saves that HTML as a document, opens it up in another instance of Excel, then grabs that formatted HTML and places it in the original document; that way you would have two columns, one with the HTML, and one with the output. It would be very unsightly though. Don't do it :0)

like image 57
ScottF Avatar answered Sep 09 '25 18:09

ScottF


Pasting html data in excel will result in the html being properly displayed in excel. The one issue with this is that carriage returns and tabs will be pasted to the next cell.

Dim objData As New DataObject
objData.SetText(sHTML)
Clipboard.SetDataObject(objData)
objRange.PasteSpecial()

Will fill a cell with properly formated text

like image 45
Rick Avatar answered Sep 09 '25 19:09

Rick