Create a javascript spreadsheet from a CSV file
The example below helps you to create a javascript spreadsheet table based on a remote CSV file, including the headers.
NOTE: A download can be performed by CTRL+S or by the option save available in the contextMenu trigged by the right click of the mouse
Source code
<html>
<script src="https://jexcel.net/v5/jexcel.js"></script>
<link rel="stylesheet" href="https://jexcel.net/v5/jexcel.css" type="text/css" />
<script src="https://jexcel.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jexcel.net/v5/jsuites.css" type="text/css" />
<div id="spreadsheet"></div>
<p><button onclick='mySpreadsheet.download();'>Export my spreadsheet as CSV</button></p>
<script>
mySpreadsheet = jexcel(document.getElementById('spreadsheet'), {
csv: '/jexcel/arts.csv',
tableOverflow: true,
columns: [
{ type: 'text', width: '300px' },
{ type: 'text', width: '80px' },
{ type: 'dropdown', width: '120px', source: ['England','Wales','Northern Ireland','Scotland'] },
{ type: 'text', width: '120px' },
{ type: 'text', width: '120px'},
],
license: '39130-64ebc-bd98e-26bc4',
});
</script>
</html>
Other properties related to CSV usage
Property |
Description |
csvFileName |
Default filename when the user download the table content. Default: 'jexcel.csv' |
csvHeaders |
Consider the first line in the CSV as the header names. Default: true |
csvDelimiter |
Consider the first line in the CSV as the header names. Default: , |
allowExport |
Allow the user to export by CTRL+S or by the contextMenu. Default: true |