iam unable to export table in excel format with following code in LWC (Salesforce) #3040
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#3040
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
HTML:
Java ScriptCode:
import { LightningElement, api, wire,track } from 'lwc';
import getWSAPVariation from "@salesforce/apex/WeatherStationReport.getWSAPReport";
import XLSX from '@salesforce/resourceUrl/SheetJS';
import { loadScript, loadStyle } from 'lightning/platformResourceLoader';
import TabularCSS from '@salesforce/resourceUrl/tabulatorCSS';
import TabularJS from '@salesforce/resourceUrl/tabulatorJS';
export default class WsActualPercentVariationReport extends LightningElement {
@api weatherStationName;
@track isFound = false;
details = [];
}
Which part is failing? Does the Salesforce LWC demo (https://docs.sheetjs.com/docs/demos/cloud/salesforce) work for you?
The compiler returning at this line
const ws = XLSX.utils.table_to_sheet(table);
Is it possible to export the HTML table to excel file in LWC?
It may be a LWC limitation. We'll take another look when we revisit the salesforce demo
https://docs.sheetjs.com/docs/demos/cloud/salesforce#exporting-data-from-sf-list It might be easier to directly inspect and export the captured data (
details
in your example). Read the linked section of the demo to see how to transform the dataThank you for your prompt response.
Is it possible to export data in given excel file format (with styles) by using community edition of sheetJS?. Can you please refer the attachment and confirm
Hello @murali,
Are you able to download file but in a format other than excel or you are not able to download file at all?
I'm having this issue currently.
I have some LWCs used in a community which are rendering some tables with data. I'm able to download table contents, but it does not work all the time.
It works well in Development and Testing environments, but not in Production.
I noticed it does not work for in Chrome and MS Edge browsers in normal window, but it is working in Incognito window.
I tried in Firefox and it works well.
For other developers in my team it works well in all browsers.
I tried to clear cache of the browsers, relaunch them and even set back to default settings but it still does not download the file in right format.
It is downloading a weird file with a weird system name (e.g. bc563f4c-de88-4ad8-8e31-e16a5808f361).
Most likely it's not related to the library, because it's working for other team members, but any idea to what it could be related? @sheetjs
Retested the LWC demo against version 59.0 and it appears to work as expected. That example exports a SF list to
SheetForceExport.xlsx
To test the HTML table case:
Follow https://docs.sheetjs.com/docs/demos/cloud/salesforce and produce the final component and page.
Replace
force-app/main/default/lwc/sheetComponent/sheetComponent.html
with the following:(it has a simple HTML table with a known class)
force-app/main/default/lwc/sheetComponent/sheetComponent.js
with the following:SF@USER.NAME
with the unique Username:Note how the table is identified. The assigned ID in the component HTML may be changed by LWC, so the recommended approach involves other DOM properties (e.g. class names or
data-
attributes on the TABLE element)@dan.cojocari there are known issues where Chrome may mangle the name of the export. As the library uses standard browser APIs to initiate a download, it is unclear how to address the issue without using nonstandard browser behaviors.