DashaLuna DashaLuna - 1 year ago 66
CSS Question

Table borders don't display properly when converted from HTML page into MS Word 2003

I've got a bit of a complicated set up. I specialise in XSLT which I write for 3rd party system. All CSS looks fine in the browser. Now that system provides a button that converts my generated HTML into MS Word 2003.

However, table borders don't convert as they appear in a Browser. There are lots of tables and they have different borders setup. For example there is one that uses only outside border and no borders inside it. When converting to MS Word, a table appears with ALL the borders in between cells. Which I don't want.

I've tried search the Internet, but didn't come across anything useful. Maybe there are tips or tricks on how to set up tables borders so it's understood properly by MS Word.

The third party said the following: "The system just passes the HTML created through the converter it finds in the installed version of Word".

I would really appreciate any tips and help!

Answer Source

I was trying to get a table with only the outer border and no inside ones. I've been trying the following HTML:

<table border="1" frame="border" rules="none" cellpadding="4" cellspacing="0">

However, in the Word that table appears with both outer and inner borders, not just with outer border as I was trying to get it.

Well, that is what border does. Hmm. You say inline CSS doesn't get picked up, so I guess both this:

 <table style="border: 1px black solid" ....>

or surrounding the table with a <div>

 <div style="border: 1px black solid"><table .....></table></div>

won't work? Those would be the most elegant solutions.

If all that fails, why not put the table into a table?

<table border="1" bordercolor="black" cellspacing="0" cellpadding="0">
  <table .... Your table  ........> </table>

it's a horrible practice to use in 2010 from a web design point of view, but if it's the only workaround so you can import the page correctly, maybe it's necessary. I'm pretty sure however that some form of CSS must work. Maybe a different notation or something. But I'm no Word HTML expert.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download