Thoughtful, detailed coverage of the Mac, iPhone, and iPad, plus the TidBITS Content Network for Apple consultants.

Taming Your Tables

If you've ever played around with HTML, you know that typing HTML is a picky, but usually straightforward process. HTML tables can be far more complex than normal HTML. You start a table with a <TABLE> tag and - as you might guess - you end a table with a </TABLE> tag. But, when it comes to specifying where rows and cells start, text alignment, how many columns or rows a given cell spans, and so on, setting up tables turns complicated. Try converting a ten-page spreadsheet with oodles of formatting into an HTML table, and you'll turn into a whimpering mass of protoplasm, begging for a magic wand to simplify the process.

Although a number of full-blown Web authoring programs help you create tables, few convert existing tables into HTML (the main exception is the $5 shareware BBEdit HTML Tables, a BBEdit extension).

< bbedit-html-tables-101.hqx>

Fortunately, help is at hand through a number of non-commercial programs that convert tab-delimited text files into HTML tables. (For those of you who tuned in recently to the world of computers, you can save most any spreadsheet, database, or word processor table in tab-delimited format. As always, test this on your data before depending on it!) This article won't cover everything available, so I apologize in advance if I missed your personal favorite. Instead, I'm going to mention a few tools I consider to be the most valuable. All of these tools are available in the HTML directory at any Info-Mac mirror.


TableMaker -- If you don't mind a small learning curve and crave sophistication and flexibility, I recommend Sam Choukri's $5 shareware TableMaker 1.0.1, which converts a tab- or comma-delimited text file into an HTML document containing the file in table format. TableMaker's documentation clearly explains how to tweak the application via a text-based settings file, where it enables you to set a caption, custom alignment, cellspacing and cellpadding, border thickness, and so on. If you insert special codes into the text file, you can create cells that span more than one row or column, using the HTML attributes rowspan and colspan.

If I could change one thing about TableMaker, I'd change the way it makes me navigate an Open dialog to open my TableMaker Settings file each time I do a conversion, especially since the dialog contains no directions and I occasionally become confused and re-open the text file instead.

Interestingly, the TableMaker Web site has an interactive version of TableMaker for use over the Web.

< tablemaker.html>

HTML TableTool -- For ease of use and converting upper-ASCII characters (but not reserved characters) to entities, try HTML TableTool 1.1.2, a freeware utility by Bertil Holmberg that requires HyperCard or HyperCard Player. Unlike most table-making utilities, TableTool presents users with a console-like interface for setting up some aspects of how you want to create a table. You then use the Open button to open a tab-delimited text file, and HTML TableTool responds by putting its HTML output in an editable field within HyperCard. You can tweak the output (if you like) and copy the text into another application; you can also save the code as a text file. Unlike TableMaker, which exports complete HTML documents, HTML TableTool outputs only the HTML needed to create the table. HTML Table Tool's upper-ASCII conversion can be turned off for long files.

Text->Table -- Nathan Cook's Text->Table 1.1 is a freeware utility that pops up a dialog box in response to you using it to open a tab-delimited text file. The dialog box offers a few options: you can enter a caption, specify whether the resulting file should have just the table tags or also have the necessary tags to create an HTML document. You can also set a few options, like whether it will have a border and whether the first row should have header-style cells or data-style cells.

TableCloth -- TableCloth 1.5.2, an AppleScript emailware applet by Ben Elroy, converts tab-delimited text to tables. To use it, you drop a text file on the applet's icon and then work your way through a few dialog boxes that let you set some aspects of your soon-to-be exported table. You can set any attributes you like within the <TABLE> tag (such as border thickness and cell padding) as well as any attributes inside all row tags and all data cell tags. TableCloth outputs tables as complete HTML documents.


Speed -- For the smallish tables typically found on the Web, all four utilities create the necessary HTML within just a second or two. If you need to generate big tables, you might be concerned about speed, so I tested all four utilities with a 13,500 character, tab-delimited text file. The ten by fifty cell table had a few empty cells, some cells slightly populated, and a few cells filled with large paragraphs of text.

TableMaker flew through the sample file in about two seconds. HTML TableTool took about five seconds with high-ASCII conversion off, and a bit over a minute with conversion on. Text->Table took about 30 seconds, and I kept my fingers crossed the entire time because the application gave no indication it was working and displayed a white area on my monitor where its dialog box had been. TableCloth was the slowest of the lot. The first time I tried TableCloth, it churned away for about three minutes and then complained about being out of memory. I quit TableCloth, increased its preferred size from 200K to 1000K, and tried again. On my second try, TableCloth still took three minutes, but completed the job with no problem.

What to Use -- Each application works differently and has its own set of pluses and minuses. Generally speaking, for the best marriage of ease of use with flexibility and friendliness, go with HTML TableTool. It's also the only program converts high-ASCII characters to entities.

Text->Table is perhaps the simplest utility of them all, so if it provides the features you need, you might find it a good choice. Text->Table is also perhaps the fastest to interface with for small tables - it puts up one dialog box that offers a few basic options and then it gets out of your way and does its thing. TableCloth is easy to use, it does give you a little more flexibility in a few instances, and - because it's an AppleScript - script-savvy HTML authors may be able to incorporate it into a larger sequence of events. TableMaker is perhaps the most sophisticated and was by far the fastest on my speed test, but it requires you to edit a text file.

Also, if you own Excel, you may find it more efficient to import your text file into Excel. You can do visual formatting within Excel and then use Excel to create an HTML table, as explained in the next article, "Excel, HTML Tables, and You."


PDFpen and PDFpenPro 9 add 100+ enhancements to improve your PDF
editing experience, with annotations, Tables of Contents, and more
export options. For PDF reviewing, editing, signing, redacting and
exporting, PDFpen has you covered. <>