This tutorial will explain what to do in order to generate a list of table rows, so you can easily insert that into a topic post here on the Tracker.


First, you will need to download Ruby from this page. Download at least version “Ruby 1.8.7-p249 (RC2)”.

When the download completes, start the setup.

  • Install Ruby into the default installation path.
  • Tick both additional options.
  • Click Install

After the installation of Ruby completes, download this zip file. Unzip the contents to a folder on you hard drive. In this example we will unzip to C:\Temp.

Open the create_table.rb file in notepad. The contents of the file are:

str = <<-EOS  
First row, cell 1  
First row, cell 2  
First row, cell 3  
First row, cell 4  
First row, cell 5  
First row, cell 6  
Second row, cell 1  
Second row, cell 2  
Second row, cell 3  
Second row, cell 4  
Second row, cell 5  
Second row, cell 6  
And  
so  
on  
until you have  
created your entire  
list of cells  
EOS  

puts "<table>"  
str.split("\n").each_slice(6) do |*items|  
   puts "<tr><td>#{items.join("</td><td>")}</td></tr>"  
end  
puts "</table>"  
  • Edit the content between str = <<-EOS and EOS to your liking.
  • Edit the value each_slice(6) to the number of columns that are supposed to be generated. (For example: change 6 to 4 to generate only four columns).
  • Save the file and close notepad.
  • Double click the generate_table.cmd file. It will run the ruby script and output the table with html markup in a file called “table_output.txt” in the same directory.

Example output using the script above:

<table>
<tr><td>First row, cell 1 </td><td>First row, cell 2</td><td>First row, cell 3</td><td>First row, cell 4</td><td>First row, cell 5</td><td>First row, cell 6</td></tr>
<tr><td>Second row, cell 1 </td><td>Second row, cell 2</td><td>Second row, cell 3</td><td>Second row, cell 4</td><td>Second row, cell 5</td><td>Second row, cell 6</td></tr>
<tr><td>And</td><td>so</td><td>on</td><td>until you have</td><td>created your entire</td><td>list of cells</td></tr>
</table>

You can now copy the contents of this file and paste it in a post on the Tracker.


End result

The final result in a post on the tracker will look like this:

First row, cell 1 First row, cell 2 First row, cell 3 First row, cell 4 First row, cell 5 First row, cell 6
Second row, cell 1 Second row, cell 2 Second row, cell 3 Second row, cell 4 Second row, cell 5 Second row, cell 6
And so on until you have created your entire list of cells
  • Hi, Nice tutorial, But can we use online table generators? like: http://www.bagism.com/tablemaker/ http://www.quackit.com/html/html_table_generator.cfm Instead of downloading an application? Thanks, Tempo – Tempo over 3 years ago
  • Sure, but I don’t know if all formatting options are available that an online table generator would offer. If there is a good online generator that also offers cell input we can include this here. – birkoff over 3 years ago

Return to Knowledge Base