Table in html with excel classes

0

<!DOCTYPE html>
<html>
<head>
</head>
<body>

<table>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
  <tr>
    <td>Ernst Handel</td>
    <td>Roland Mendel</td>
    <td>Austria</td>
  </tr>
  <tr>
    <td>Island Trading</td>
    <td>Helen Bennett</td>
    <td>UK</td>
  </tr>
  <tr>
    <td>Laughing Bacchus Winecellars</td>
    <td>Yoshi Tannamuri</td>
    <td>Canada</td>
  </tr>
  <tr>
    <td>Magazzini Alimentari Riuniti</td>
    <td>Giovanni Rovelli</td>
    <td>Italy</td>
  </tr>
</table>

</body>
</html>

I wonder if there are ready-made bootstrap classes or some other library that leaves tables with the same format as excel.

    
asked by anonymous 01.12.2017 / 12:30

1 answer

1

You can use this framework:

link

It is not necessarily just css classes like the bootstrap, but goes much further:

  
  • Resizable columns
  •   
  • Excel-style headers that the user or programmer can hide
  •   
  • Can be displayed in zebra-striped mode for better presentation
  •   
  • Data can be passed to initialize the worksheet
  •   
  • The user or programmer can add and delete rows and columns
  •   
  • Unlike other spreadsheets, display only as many rows and columns as you need.
  •   
  • Add or delete them in your script as needed, or allow a user to do so.
  •   
  • Data can be deleted, copied and pasted from / to a   single cell or an entire row, within a worksheet or between   multiple worksheets Keyboard interaction (keys Ctrl + C, Ctrl + V,   Enter and Tab / Shift + Tab) Data can be retrieved in one   Two-dimensional string array Multiple worksheets can be displayed   on a fully exposed API page
  •   

An example code made with it:

Instead of a table in your html, you will have to enter a DIV:


<div id = "contents" style = "margin-bottom: 20px">

The secret of how it will behave is in the javascript code:

    $(document).ready(function () {  
         var aData = [ [ "Redwood City", "300", "true" ], [ "San Francisco", "100", "true" ], [ "San Jose", "500", "false" ] ];
         var oTable = $( "div#contents" ).spreadsheet( 
          { rows: 0, cols: 0, data: aData, zebra_striped: true, read_only: false, rowheader: true, colheader: true } );
         oTable.setNumeric( 1, true );
         $( "div#contents2" ).spreadsheet( 
          { rows: 10, cols: 10, data: null, zebra_striped: false, read_only: false, rowheader: true, colheader: true } );
    } );
  

Each parameter of this does some kind of action when initializing the framework   in div "contents"

For more parameter information see the documentation:

link

Remember that it depends on the jQuery framework.

    
01.12.2017 / 12:48