toCSV¶
webix.
toCSV
(id, options)¶webix.toCSV helper.
Please look into the linked official documentation.
External references¶
Code¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | webix.toCSV = function(id, options){
var view = webix.$$(id);
options = options || {};
if (view.$exportView)
view = view.$exportView(options);
options._export_mode = "csv";
var scheme = getExportScheme(view, options);
var result = getExportData(view, options, scheme);
var data = getCsvData(result, scheme);
var filename = (options.filename || "Data")+".csv";
var blob = new Blob([data], { type: "text/csv" });
webix.html.download(blob, filename);
};
function getCsvData(data, scheme) {
var final = [[]];
for (var i=0; i<scheme.length; i++)
final[0][i] = (scheme[i].header[0]||"").replace(/<[^>]*>/gi,"");
return webix.csv.stringify(final.concat(data));
}
var font;
|