You need to sign in to do that
Don't have an account?
jishan roy
How to upload and insert data through Excel in salesforce lwc
The requirement is show the excell file in object-account in lwc.
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Check below examples that can help you.
https://hicglobalsolutions.com/blog/how-to-import-records-using-lighting-web-component/
https://www.apexhours.com/export-to-csv-xls-using-lightning-web-component/
https://www.salesforcetroop.com/custom_file_upload_using_lwc
Please mark as Best Answer if above information was helpful.
Thanks,
Hi Jishan
Please follow below url:-
https://chowdera.com/2021/03/20210328020859302q.html
https://developer.salesforce.com/forums/?id=9062I000000INoNQAW
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
my query is I write the j.s. but how to write apex for that i want to know,
here is my code:
import { LightningElement, track } from 'lwc';
import { loadScript } from 'lightning/platformResourceLoader';
import sheetmin from '@salesforce/resourceUrl/sheetmin';
let XLS = {};
export default class xlsxDemo extends LightningElement {
@track acceptedFormats = ['.xls', '.xlsx'];
connectedCallback() {
console.log('connected callback');
Promise.all([
loadScript(this, sheetmin )
]).then(() => {
XLS = XLSX
})
}
handleUploadFinished(event){
const uploadedFiles = event.detail.files;
console.log('uploadedFiles',uploadedFiles);
if(uploadedFiles.length > 0) {
this.ExcelToJSON(uploadedFiles[0])
}
}
ExcelToJSON(file){
var reader = new FileReader();
reader.onload = event => {
var data=event.target.result;
var workbook=XLS.read(data, {
type: 'binary'
});
var XL_row_object = XLS.utils.sheet_to_row_object_array(workbook.Sheets["Sheet1"]);
var data = JSON.stringify(XL_row_object);
console.log(JSON.stringify(data));
};
reader.onerror = function(ex) {
this.error=ex;
this.dispatchEvent(
new ShowToastEvent({
title: 'Error while reding the file',
message: ex.message,
variant: 'error',
}),
);
};
reader.readAsBinaryString(file);
}
}
please help me out how to write apex for this requirement.