Convert/normalize HTML table containing colspan & rowspan...

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
alnico
Posts: 74
Joined: Fri Oct 12, 2007 11:57 pm

Convert/normalize HTML table containing colspan & rowspan...

Post by alnico »

Has anybody already created such a script?
I am looking for a script filter that can take a cleaned HTML table containing colspan & rowspan attributes and un-combine/split them into their own cell.

Input would look something like this:

Code: Select all

<table>
  <tr>
    <td colspan="4">abcd</td>
    <td>e</td>
  </tr>
  <tr>
    <td>f</td>
    <td>g</td>
    <td>h</td>
    <td colspan="2">ij</td>
  </tr>
  <tr>
    <td>k</td>
    <td>l</td>
    <td colspan="2" rowspan="2">mnrs</td>
    <td>o</td>
  </tr>
  <tr>
    <td rowspan="2">pu</td>
    <td>q</td>
    <td>t</td>
  </tr>
  <tr>
    <td>v</td>
    <td>w</td>
    <td>x</td>
    <td>y</td>
  </tr>
</table>
Output would look like this:

Code: Select all

<table>
  <tr>
    <td>abcd</td>
    <td>abcd</td>
    <td>abcd</td>
    <td>abcd</td>
    <td>e</td>
  </tr>
  <tr>
    <td>f</td>
    <td>g</td>
    <td>h</td>
    <td>ij</td>
    <td>ij</td>
  </tr>
  <tr>
    <td>k</td>
    <td>l</td>
    <td>mnrs</td>
    <td>mnrs</td>
    <td>o</td>
  </tr>
  <tr>
    <td>pu</td>
    <td>q</td>
    <td>mnrs</td>
    <td>mnrs</td>
    <td>t</td>
  </tr>
  <tr>
    <td>pu</td>
    <td>v</td>
    <td>w</td>
    <td>x</td>
    <td>y</td>
  </tr>
</table>
colspan would be pretty easy to handle...simply insert...<td colspan="4">abcd</td>...four times in succession and remove the colspan attributes.
Exp: <td>abcd</td><td>abcd</td><td>abcd</td><td>abcd</td>

rowspan is a little more tricky, as you need to track the placement of the rowspan containing tag and insert it x times in the same location in rows below it.

Thanks for any help,

Brent
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Convert/normalize HTML table containing colspan & rowspan...

Post by DataMystic Support »

You'll have to use a VBScript filter to generate this.
alnico
Posts: 74
Joined: Fri Oct 12, 2007 11:57 pm

Re: Convert/normalize HTML table containing colspan & rowspan...

Post by alnico »

Yep, I meant to inquire if anybody that built such a VBScript as it seems somewhat of a standard task.

If not, anybody do it on commission?

Thanks, Brent
Post Reply