Create Excel comment from HTML source

This way you can create an excel file from Html. And I found that many things are possible, such as adding images, formatting, etc. Only with some CSS settings.

However, what I'm trying to do now is get a small red triangular comment.

I created a clean excel file containing only a comment, but the generated html is a mess. And I'm sure a lot of this is superfluous. Has anyone done this or knows how I can make it work?

It would be nice if it were as simple as <td title="comment">text</td> , but it is not.

EDIT: I have basic requirements for html to show a comment when loading in excel reduced to this ... I just need to see if I can crop vml to something simpler.

It looks like the link to the cell to which it is connected is as follows: 0 0

Now I just need to position it correctly, initially

I think this is the minimum, and I added a second comment, slightly modifying the html.

But, if you can help trim this further, let it be minimal, which would be very useful

 <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"> <body> <table> <tr> <td>cell 1</td> </tr> <tr> <td></td> <td></td> <td></td> <td>cell 3</td> </tr> </table> <div style='mso-element:comment-list'> <div style='mso-element:comment'> <!--[if gte mso 9]> <xml> <v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"> <v:stroke joinstyle="miter"/> <v:path gradientshapeok="t" o:connecttype="rect"/> </v:shapetype> <v:shape id="_comment1" type="#_x0000_t202" style='width:96pt;height:55.5pt;z-index:1;visibility:hidden' fillcolor="infoBackground [80]" o:insetmode="auto"> <v:textbox style='mso-direction-alt:auto'/> <x:ClientData ObjectType="Note"> <x:Row>0</x:Row> <x:Column>0</x:Column> </x:ClientData> </v:shape> <v:shape id="_comment2" type="#_x0000_t202" style='width:96pt;height:55.5pt;z-index:1;visibility:hidden' fillcolor="infoBackground [80]" o:insetmode="auto"> <v:textbox style='mso-direction-alt:auto'/> <x:ClientData ObjectType="Note"> <x:Row>1</x:Row> <x:Column>3</x:Column> </x:ClientData> </v:shape> </xml> <![endif]--> <div v:shape="_comment1" > This is a comment </div> <div v:shape="_comment2" > This is another comment </div> </div> </div> </body> </html> 
+2
source share
3 answers

I think this is the minimum, and I added a second comment, slightly modifying the html.

 <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"> <body> <table> <tr> <td>cell 1</td> </tr> <tr> <td></td> <td></td> <td></td> <td>cell 3</td> </tr> </table> <div style='mso-element:comment-list'> <div style='mso-element:comment'> <!--[if gte mso 9]> <xml> <v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"> <v:stroke joinstyle="miter"/> <v:path gradientshapeok="t" o:connecttype="rect"/> </v:shapetype> <v:shape id="_comment1" type="#_x0000_t202" style='width:96pt;height:55.5pt;z-index:1;visibility:hidden' fillcolor="infoBackground [80]" o:insetmode="auto"> <v:textbox style='mso-direction-alt:auto'/> <x:ClientData ObjectType="Note"> <x:Row>0</x:Row> <x:Column>0</x:Column> </x:ClientData> </v:shape> <v:shape id="_comment2" type="#_x0000_t202" style='width:96pt;height:55.5pt;z-index:1;visibility:hidden' fillcolor="infoBackground [80]" o:insetmode="auto"> <v:textbox style='mso-direction-alt:auto'/> <x:ClientData ObjectType="Note"> <x:Row>1</x:Row> <x:Column>3</x:Column> </x:ClientData> </v:shape> </xml> <![endif]--> <div v:shape="_comment1" > This is a comment </div> <div v:shape="_comment2" > This is another comment </div> </div> </div> </body> </html> 
+1
source

There is no easy way I could determine. But here is the hard way:

  • Take your simple html file and open it in Excel.
  • Add a comment to the cell.
  • Save it by saving the html format.

The reason this is not easy is because it is in fact Excel at this stage that it creates a folder containing some support files, and the new version of the source files is essentially a representation of the Excel HTML file. If you re-open this file with support files, you will receive your comment.

This suggests that there is a prospective html format (although it does not exist in a single file) that gives you your comment, and you just need to expand it.

So maybe? Yes. It's worth it? Well, given that Microsoft never wrote anything in hundreds of lines of code that they could not write in a thousand - almost certainly not.

I am curious what else you could accomplish in that direction. I made this answer to the community wiki so you can share it if you're interested.

+2
source

It was so timely and highly appreciated! I just implemented now and it seems to be working fine. The biggest problem is to predefine the line and col which are "flex" for me. I look to see if you can use an anchor instead of a row and column.

0
source

All Articles