This page lists files in the current directory. You can view content, get download/execute commands for Wget, Curl, or PowerShell, or filter the list using wildcards (e.g., `*.sh`).
wget 'https://sme10.lists2.roe3.org/mdrone/Table2CSV/Table2CSV.zip'
wget 'https://sme10.lists2.roe3.org/mdrone/Table2CSV/example.html'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Table2CSV Example</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="tableToCsv.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-12">
<h3>Example jQuery tableToCsv</h3>
</div>
<div class="col-xs-12">
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Head 1</th>
<th colspan="2">Head 2 and 3</th>
<th>Head 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
<td>Data 4</td>
</tr>
<tr>
<td>D1</td>
<td>D2</td>
<td>D3</td>
<td>D4</td>
</tr>
<tr>
<td>A1</td>
<td>A2</td>
<td>A3</td>
<td>A4</td>
</tr>
<tr>
<td>X1</td>
<td>X2</td>
<td>X3</td>
<td>X4</td>
</tr>
<tr>
<td>Y1</td>
<td>Y2</td>
<td>Y3</td>
<td>Y4</td>
</tr>
</tbody>
</table>
</div>
<div class="col-xs-12 text-center">
<button onClick="exportCsv()" class="btn btn-info">Export to CSV</button>
<button onClick="generateCsv()" class="btn btn-primary">Generate CSV</button>
</div>
<div class="col-xs-12" style="margin-top: 10px;">
<pre id="csv"></pre>
</div>
</div>
</div>
<script>
function exportCsv()
{
$('table').tableToCsv({
filename: 'example.csv',
colspanMode: 'replicate'
});
}
function generateCsv()
{
let csv = $('table').tableToCsv({
colspanMode: 'replicate',
autoDownload: false
});
$('#csv').html(csv);
}
</script>
</body>
</html>
wget 'https://sme10.lists2.roe3.org/mdrone/Table2CSV/tableToCsv.js'
(function($) {
$.tableToCsv = {
name: 'tableToCsv',
version: '1.0',
release: '2021-03-22',
author: 'Paulo Kramer',
site: 'https://www.paulokramer.com',
documentation: 'https://github.com/PauloAK/jQuery-tableToCsv'
};
$.fn.tableToCsv = function(options) {
var settings = $.extend({
filename: null, // Set the filename to download, eg: filename.csv
separator: ',', // Set the CSV separator token
colspanMode: 'empty', // Set the colspan mode, can be empty or replicate
autoDownload: true, // If it's true, the plugin auto downloads the csv, otherwise, returns the csv content
fn_onInit: null, // Custom function called before start processing
fn_onComplete: null, // Custom function called after processing, right before start download/return
fn_onError: null // Custom function called on error
}, options);
let enabledColspanModes = [ 'empty', 'replicate' ];
try {
if (!this.is('table'))
throw `Selected element isn't a table`;
if (settings.autoDownload && !settings.filename.length)
throw 'You need to specify a filename';
if (enabledColspanModes.indexOf(settings.colspanMode) === -1)
throw `You need to specify a valid colspan mode, available: ${enabledColspanModes.join(', ')}`;
if (typeof settings.fn_onInit == "function") settings.fn_onInit();
let $table = this;
let csvString = _t2csv_parseTable($table, settings.separator);
if (typeof settings.fn_onComplete == "function") settings.fn_onComplete();
return settings.autoDownload ? _t2csv_download(csvString) : csvString;
} catch (error) {
console.error(`[${$.tableToCsv.name}::Error] ${error}`);
if (typeof settings.fn_onError == "function") settings.fn_onError();
return;
}
function _t2csv_parseTable(table)
{
const rows = table.find('tr');
return [].slice.call(rows)
.map(function(row) {
const cells = row.querySelectorAll('th,td');
return [].slice.call(cells)
.map(function(cell) {
return _t2csv_escapeContent(cell.textContent) + _t2csv_generateColSpan(cell);
})
.join(settings.separator);
})
.join('\n');
}
function _t2csv_generateColSpan(cell)
{
if (!cell.hasAttribute('colspan') )
return '';
colspanContent = ( settings.colspanMode === 'replicate' ? _t2csv_escapeContent(cell.textContent) : _t2csv_escapeContent(''));
let colspanString = `${settings.separator}${colspanContent}`;
return colspanString.repeat( (parseInt(cell.getAttribute('colspan')) - 1) );
}
function _t2csv_escapeContent(content)
{
content = content.replace(/(\r\n|\n|\r)/gm, '').replace(/(\s\s)/gm, ' ').replace(/"/g, '""');
return `"${content}"`;
}
function _t2csv_download(content) {
let link = document.createElement('a');
link.setAttribute('href', `data:text/csv;charset=utf-8,${encodeURIComponent(content)}`);
link.setAttribute('download', settings.filename);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
};
}(jQuery));
wget 'https://sme10.lists2.roe3.org/mdrone/Table2CSV/tableToCsv.min.js'
!function(e){e.tableToCsv={name:"tableToCsv",version:"1.0",release:"2021-03-22",author:"Paulo Kramer",site:"https://www.paulokramer.com",documentation:"https://github.com/PauloAK/jQuery-tableToCsv"},e.fn.tableToCsv=function(t){var n=e.extend({filename:null,separator:",",colspanMode:"empty",autoDownload:!0,fn_onInit:null,fn_onComplete:null,fn_onError:null},t);let o=["empty","replicate"];try{if(!this.is("table"))throw"Selected element isn't a table";if(n.autoDownload&&!n.filename.length)throw"You need to specify a filename";if(-1===o.indexOf(n.colspanMode))throw`You need to specify a valid colspan mode, available: ${o.join(", ")}`;"function"==typeof n.fn_onInit&&n.fn_onInit();let t=function(e){const t=e.find("tr");return[].slice.call(t).map(function(e){const t=e.querySelectorAll("th,td");return[].slice.call(t).map(function(e){return r(e.textContent)+function(e){if(!e.hasAttribute("colspan"))return"";return colspanContent="replicate"===n.colspanMode?r(e.textContent):r(""),`${n.separator}${colspanContent}`.repeat(parseInt(e.getAttribute("colspan"))-1)}(e)}).join(n.separator)}).join("\n")}(this,n.separator);return"function"==typeof n.fn_onComplete&&n.fn_onComplete(),n.autoDownload?function(e){let t=document.createElement("a");t.setAttribute("href",`data:text/csv;charset=utf-8,${encodeURIComponent(e)}`),t.setAttribute("download",n.filename),t.style.display="none",document.body.appendChild(t),t.click(),document.body.removeChild(t)}(t):t}catch(t){return console.error(`[${e.tableToCsv.name}::Error] ${t}`),void("function"==typeof n.fn_onError&&n.fn_onError())}function r(e){return`"${e=e.replace(/(\r\n|\n|\r)/gm,"").replace(/(\s\s)/gm," ").replace(/"/g,'""')}"`}}}(jQuery);