0

I convert an Excel file into html table with the PHPExcel library.

EDITED output : https://jsfiddle.net/simsimzzz/d1ccqveq/15/

How can I ( JQuery ? ) fix the top row as a <thead>?

    <table border="0" cellpadding="0" cellspacing="0" id="sheet0" class="sheet0 gridlines">
        <colgroup>
        <col class="col0">
        <col class="col1">
        <col class="col2">
        <col class="col3">
        </colgroup>
<tbody>
          <tr class="row0">
            <td class="column0 style3 s">Client Type</td>
            <td class="column1 style3 s">Client</td>
            <td class="column2 style3 s">N° Incident</td>
            <td class="column3 style3 s">blabla</td>
</tr>
</tbody>

PHPExcel doesn't generate <thead></thead>..

EDIT : Now I have a <thead></thead> , how can I fix this one and keep the width of cells according to the <tbody>

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Simon Delaunay
  • 145
  • 1
  • 18

1 Answers1

2

Seems that you need create a <thead> then move the header row into it, from of the <tbody>.

Try this :

jQuery(function($) {
    var $table = $('#sheet0'); // select the table of interest
    var $thead = $('<thead/>').prependTo($table); // create <thead></thead>
    $table.find('tbody tr').eq(0).appendTo($thead); // move the header row from tbody into thead

    // Now the table is ready to have your chosen method applied to fix the position of the thead.

});
Roamer-1888
  • 19,138
  • 5
  • 33
  • 44