Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Easily convert MS Word tables to clean HTML code Apps
Recently I started a new contract, and the new people I work with like to create Microsoft Word tables. They send me these tables in a Word document, so that I can post them on their site as HTML tables in their CMS system. Having not done much work with Word, I set about to find a way to convert the Word table to a clean HTML format without requiring some expensive or large HTML editor. After much asking around, and searching, I accidently discovered this simple method using just Word and BBEdit:
  1. Select the entire table in Word and copy to the clipboard.
  2. Open a new document in BBEdit and past the copied clipboard into this new document. Here you will see that the table gets pasted in a tab-delimited format.
  3. Select Markup » Tables » Convert to Table. Adjust the preferences for the conversion as needed, and click on Convert.
You will now have a clean HTML table, ready to place into your page layout.

[robg adds: This hint was accidentally published yesterday before I had a chance to review it, hence the two existing comments dated from yesterday. I use Smultron extensively, but in contrast with the comment below, as far as I know it cannot handle the conversion of a text block to HTML table code. I also tested TextWrangler, and I don't think it will handle this conversion. I'm sure there must be other tools for this task, though, so if you know of them, please post.]
    •    
  • Currently 4.00 / 5
  You rated: 5 / 5 (6 votes cast)
 
[35,908 views]  

Easily convert MS Word tables to clean HTML code | 11 comments | Create New Account
Click here to return to the 'Easily convert MS Word tables to clean HTML code' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Easily convert MS Word table to clean HTML format
Authored by: JimAkin on Apr 16, '07 10:00:17AM

Good hint, but a better headline for it would be something like "Use BBEdit to convert Word tables to clean HTML".

Tasks that require commercial apps can certainly qualify as hints if they're undocumented, not obvious, etc. But it seems only fair to give implicit warning when something can only be done "easily" if you own a $125 program.

Thanks,

Jim

---
Jim



[ Reply to This | # ]
Easily convert MS Word table to clean HTML format
Authored by: morbium on Apr 16, '07 10:28:38AM
There are several free apps that can do the same thing
like:

Smultron
http://smultron.sourceforge.net

TextWrangler 2 (the free bbedit version)
http://www.barebones.com/products/textwrangler/index.shtml

It's not necessary to spend $125 just for converting
word docs to html
BBedit is a great app for codegeeks but it's
overkill to buy that just for this task

[ Reply to This | # ]
Easily convert MS Word tables to clean HTML code
Authored by: broomdodger on Apr 17, '07 08:21:34AM

I do not have MS Word, but use NeoOffice 2.1 and MacOS 10.4.7.

In NeoOffice, create a table, selected the table, Copy the table, open TextEdit, Paste the table, Saved As... HTML, open the file in Safari, and yes it has been converted to a table. The source is fairly clean.



[ Reply to This | # ]
Re: Easily convert MS Word tables to clean HTML code
Authored by: Uncle Asad on Apr 17, '07 03:22:54PM

I've found NeoOffice does a decent job of cleaning up Word-generated HTML code in general (open the .html file in the "Writer/Web" module). It doesn't get everything, but it seems to eliminate the most egregious junk and make it fairly easy to finish cleaning up manually.

Unfortunately, when exporting a spreadsheet to HTML, NeoOffice seems to redundantly style every single cell :p

Also note that TextEdit only supports tables on Mac OS X 10.4 and above....



[ Reply to This | # ]
Easily convert MS Word tables to clean HTML code
Authored by: ars on Apr 17, '07 10:13:09AM

I tested this with Word X and Textwrangler and TextEdit. Textwrangler did not work, but TextEdit made a table in html which displayed fine in Safari.



[ Reply to This | # ]
Use Yahoo Mail to convert MS Word tables to clean HTML code
Authored by: jomy on Apr 17, '07 12:35:19PM

In the past I've used Yahoo Mail's preview function to convert to well formed HTML.
Simply email the document to your Yahoo email account and then use the web preview function.
Yahoo's servers will convert the Word document to HTML.
I would then save the source of the preview page.
I did have to open it up in a editor and strip out some Yahoo specific code.



[ Reply to This | # ]
Easily convert MS Word tables to clean HTML code
Authored by: wgscott on Apr 17, '07 07:57:29PM

You can use SeaMonkey Composer (or Netscape or Mozilla composers) to format tables (copied from Word, or otherwise) and so forth and save as html.



[ Reply to This | # ]
Easily convert MS Word tables to clean HTML code
Authored by: ob1cannoli on Apr 17, '07 08:34:51PM

if you already own word/office, why not just paste into excel, save as a csv (comma separated), open in a text editor, and find-replace "," with "</td><td>" and hard-returns with "</td></tr><tr><td>"....
add a "<table><tr><td>" to the beginning, etc...



[ Reply to This | # ]
Easily convert MS Word tables to clean HTML code
Authored by: montylee on Apr 19, '07 10:15:42AM

OK, this was great. I used it with Excel and it worked flawlessly. I had been using the File-Save as Web Page in Excel and it turns out terrible tables. But this worked great and did it without all the extraneous code Microsoft sticks in.

Thanks.

Monty



[ Reply to This | # ]
Easily convert MS Word tables to clean HTML code
Authored by: brianticap on Apr 21, '07 01:14:57PM

Is it possible to do this with Textmate?

Thanks.



[ Reply to This | # ]
Easily convert MS Word tables to clean HTML code
Authored by: Abe of Lincoln on Apr 21, '07 04:12:32PM

Importing the Word document into Google Docs seems to work, too. Although I'm not equipped to judge the quality of the HTML produced.



[ Reply to This | # ]