clarketm / TableExport

The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files.
https://tableexport.travismclarke.com/
Apache License 2.0
888 stars 289 forks source link

Issue with a complex header #167

Open stla opened 5 years ago

stla commented 5 years ago

Hello,

I have such a header:

  <thead>
    <tr>
      <th colspan="2" rowspan="2">Factors</th>
      <th colspan="5">Estimated parameters</th>
    </tr>
    <tr>
      <th colspan="2">Linear regression</th>
      <th colspan="3">Quadratic regression</th>
    </tr>
    <tr>
      <th>A</th>
      <th>B</th>
      <th>C</th>
      <th>D</th>
      <th>E</th>
      <th>F</th>
      <th>G</th>
    </tr>
  </thead>

When I export to xlsx, Excel has to make a repair, and here is the result:

excel1

while it should be:

excel2

stla commented 5 years ago

When I look at the merges I have:

[{s:{r:0,c:0},e:{r:1,c:1}},{s:{r:0,c:2},e:{r:0,c:6}},{s:{r:1,c:1},e:{r:1,c:2}},{s:{r:1,c:3},e:{r:1,c:5}}]

It should be instead, I think:

[{s:{r:0,c:0},e:{r:1,c:1}},{s:{r:0,c:2},e:{r:0,c:6}},{s:{r:1,c:2},e:{r:1,c:3}},{s:{r:1,c:4},e:{r:1,c:6}}]

When I manually do the replacement, Excel (2016) still does a repair, but the repaired file is correct. And it is correct in LibreOffice, without repair.

haifahrul commented 5 years ago

In my case : when i set header with rowspan and colspan, the header look like this image

My Expectation, the header look like this, image

Any one can help?

haifahrul commented 5 years ago

In my case : when i set header with rowspan and colspan, the header look like this image

My Expectation, the header look like this, image

Any one can help?

I have investigation, and found :

If the header column set with text or value : text space number, the header exported to excel will be to formated with date. Ex. SEMESTER 4

Is it a bug?

@clarketm @PeterDaveHello @janrop @tompetko @pierresh