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 context menu.
<html>
<script src="https://jspreadsheet.com/v7/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jspreadsheet.com/v7/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />
<div id="spreadsheet"></div>
<p><button id="exportbtn">Export my spreadsheet as CSV</button></p>
<script>
let mySpreadsheet = jspreadsheet(document.getElementById('spreadsheet'), {
csv: '/jspreadsheet/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: 'MzdlNDc5ZGNhNDkzYjA4NjBkNmY5YjVkZDdiYzhkNDlmMzM5NmZlZTJlNTFiNjg1NjY1ZTZkYTE5NGNiNGE5YjhmNGU4ODUxMTZjYzVjNDEzNTUzZWU4YTgwNGI2YTE4MDI3MDdiNmRjMmVhYzk1YWRjYjZjYTY5Y2FiZGNlNDcsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94Tnprd016QXdOekk0TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0luWXhNaUlzSW5ZeE15SXNJbU5vWVhKMGN5SXNJbVp2Y20xeklpd2labTl5YlhWc1lTSXNJbkJoY25ObGNpSXNJbkpsYm1SbGNpSXNJbU52YlcxbGJuUnpJaXdpYVcxd2IzSjBaWElpTENKaVlYSWlMQ0oyWVd4cFpHRjBhVzl1Y3lJc0luTmxZWEpqYUNJc0luQnlhVzUwSWl3aWMyaGxaWFJ6SWl3aVkyeHBaVzUwSWl3aWMyVnlkbVZ5SWl3aWMyaGhjR1Z6SWl3aVptOXliV0YwSWl3aWNHbDJiM1FpWFN3aVpHVnRieUk2ZEhKMVpYMD0=',
});
document.getElementById("exportbtn").onclick = () => mySpreadsheet.download();
</script>
</html>
Other properties related
| Property | Description |
|---|---|
| csvFileName | Default filename when the user download the table content. Default: 'jspreadsheet.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 |