Hi,
Could you give me the sample code for export the grid to excel in LWC?
I'd like to use the lightning-button for exporting.
Thank you.
Hi syless,
Nothing special is required. Please see this example https://bryntum.com/products/grid/examples/exporttoexcel/
and docs https://bryntum.com/products/grid/docs/api/Grid/feature/experimental/ExcelExporter
After your grid configured all you need is to call grid.features.excelExporter.export()
in button click handler.
All the best,
Alex
Hi Alex.
Thank you for the answer.
But I still have an issue.
After importing zipcelx uploaded as a static resource, grid.features.excelExporter.export() was called. However, I get the message 'Error: ExcelExporter: "zipcelx" library is required'.
Are there any additional settings that need to be set?
import zipcelx from '@salesforce/resourceUrl/zipcelx';
renderedCallback() {
if (this.bryntumInitialized) {
return;
}
this.bryntumInitialized = true;
Promise.all([
loadScript(this, GRID + '/grid.lwc.module.js'),
loadScript(this, zipcelx + '/src/zipcelx.js'),
loadStyle(this, GRID + '/grid.stockholm.css')
])
}
handleExport(){
productGrid.features.excelExporter.export();
}
Hello.
Exporter plugin expects a handle for zipcelx library, see this doc: https://bryntum.com/products/gantt/docs/api/Grid/feature/experimental/ExcelExporter
You need to provide zipcelx to a plugin config like this:
excelExporter : { zipcelx : refToZipcelx }
So what you need is to find a global reference to this library (it was probably exported to the window object) and provide it to the feature.
Hi,
Sorry to bother you. I missed that.
As you said, I set the plugin config like below.
import zipcelx from '@salesforce/resourceUrl/zipcelx';
window.productGrid = new bryntum.grid.Grid({
features: {
excelExporter: {
zipcelx
},
}
....
});
It looks like the reference is set. However, a new problem arose.
I attached the image and zipcelx.
And importing also has problem.
class ExcelImporter extends bryntum.grid.InstancePlugin {
...
}
With above code, the component has unexpected error.
"Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details."
Can you give me a sample code for importing excel in LWC?
Thank you.