Hello,
I am attempting to implement DataTable export functionality in my TypeScript Electron desktop application. The application functions in an offline state, so I need to be able to export without accessing the webix CDN. I found the following:
The dependencies which are used for providing export possibilities are generally taken from Webix CDN online catalog. If you need to implement data export offline, you should complete the following steps:
download the package with CDN-files from https://github.com/webix-hub/cdn-extras
rename the folder to "extras" and move it to the desired directory
set the path to the local CDN repository as: `webix.cdn = "/local_folder";`
Per this, I downloaded the CDN, renamed it extras, and moved it into my local directory:
C:\\Dev\\Projects\\Electron\\app\\client\\components\\controls\\table\\extras
CSV export works great, however none of the other exports work. I will post the code below, as well as the error messages.
import "webix";
import "webix/webix.css";
import "webix/webix.js";
// we downloaded some files webix tries to get, so that we can retrieve these offline
(webix as any).cdn = "../components/controls/table";
export class WebixTableStore
{
...
protected createOptions ()
{
const columns = this.createColumnHeaders ();
const data = this.createData ();
const rules = this.createRules ();
return {
autoheight: true,
autowidth: true,
blockselect: true,
columns,
container: this.renderingNodeId,
data,
editable: true,
editaction: "dblclick",
id: this.renderingNodeId,
multiselect: true,
navigation: true,
rules,
select: "cell",
view: "datatable",
ready ()
{
const target = this as any;
target.validate ();
},
} as webix.ui.datatableConfig;
}
protected createTableWhenReady = () =>
{
this.table = (window as any).webix.ui (this.createOptions ()) as webix.ui.datatable; // any is because TS def is wrong
}
protected createTable ()
{
webix.ready (this.createTableWhenReady);
}
exportExcel = () =>
{
if (this.table)
{
webix.toExcel (this.renderingNodeId, {});
}
}
exportCSV = () =>
{
if (this.table)
{
webix.toCSV (this.renderingNodeId, {});
}
}
exportPDF = () =>
{
if (this.table)
{
webix.toPDF (this.renderingNodeId, "name");
}
}
exportPNG = () =>
{
if (this.table)
{
webix.toPNG (this.renderingNodeId, "name");
}
}
...
}
when exporting to excel:
Uncaught Error: Cannot find module './dist/cpexcel'
at Module._resolveFilename (module.js:470)
at Function.Module._resolveFilename (C:\\Dev\\Projects\\Electron\\app\\client\
ode_modules\\electron\\dist\\resources\\electron.asar\\common\\res…:35)
at Function.Module._load (module.js:418)
at Module.require (module.js:498)
at require (internal/module.js:20)
at make_xlsx (eval at webix.exec (webix.js?ca2c:1805), <anonymous>:5:15473)
at eval (eval at webix.exec (webix.js?ca2c:1805), <anonymous>:15:9597)
at eval (<anonymous>)
at Object.webix.exec (webix.js?ca2c:16)
at webix.ajax.eval (webix.js?ca2c:15)
when exporting to PDF: (notice it is missing the client
folder in the path?)
GET file:///C:/Dev/Projects/Electron/app/components/controls/table/extras/undefined.ttf net::ERR_FILE_NOT_FOUND
when exporting to PNG:
Uncaught TypeError: Cannot read property 'polyfill' of undefined
at Object.eval (eval at webix.exec (webix.js?ca2c:1805), <anonymous>:7:25235)
at eval (eval at webix.exec (webix.js?ca2c:1805), <anonymous>:8:26504)
at eval (<anonymous>)
at Object.webix.exec (webix.js?ca2c:16)
at webix.ajax.eval (webix.js?ca2c:15)
at Function.webix.ajax.$callback (webix.js?ca2c:130)
at XMLHttpRequest.G.a.onreadystatechange (webix.js?ca2c:125)
Any suggestions?