Our blazing fast Grid component built with pure JavaScript


Post by syless »

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.

Attachments
2.png
2.png (26.35 KiB) Viewed 634 times

Post by alex.l »

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


Post by syless »

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();
 }
        

Post by alex.l »

Hi,

Error message means that library was not loaded. Do you see any errors in console or Network tab?

All the best,
Alex


Post by syless »

Hi,

It seems that the zipcelx.js is loaded without issues.

But exporter doesn't seem to recognize the file.

Attachments
1.png
1.png (26.59 KiB) Viewed 596 times

Post by Maxim Gorkovsky »

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.


Post by syless »

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.

Attachments
1.png
1.png (17.56 KiB) Viewed 572 times
zipcelx.zip
(109.21 KiB) Downloaded 25 times

Post by Maxim Gorkovsky »

Hello.
We never tried to import Excel in Salesforce. I recommend enabling debug mode and checking source of the problem. Also try pausing on caught exceptions, maybe there was a hidden problem during initialization.


Post by syless »

Hi,

How much progress are you making?

Let me know if you need other information.

Thank you.


Post by alex.l »

Hi syless,

We have no idea what is the problem. As Maxim recommended above, enable debug mode and try to collect more information about this problem and post it here.

Thank you.

All the best,
Alex


Post Reply