Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we use this library without npm or yarn. #71

Open
jnarayan3039 opened this issue Jun 9, 2020 · 0 comments
Open

Can we use this library without npm or yarn. #71

jnarayan3039 opened this issue Jun 9, 2020 · 0 comments

Comments

@jnarayan3039
Copy link

Hi,

I am trying to use this library from Salesforce Lightning Web Component, I imported the downloaded zip file as a static resource and then imported the module.js into my javascript file. I am running into issues. Below is my code and explanation

@salesforce/resourceUrl/zipcelx - refers to the static resource that has entire downloaded zip reference.
In salesforce we need to call loadScript for loading individual script files for using them

import { LightningElement, track, api} from 'lwc';
import zipcelx from '@salesforce/resourceUrl/zipcelx';
import getFieldsMetadata from '@salesforce/apex/ObjectFieldsGraphController.getFieldsMetadata'
import { loadScript } from 'lightning/platformResourceLoader';

export default class SpreadSheetGenerator extends LightningElement {

renderedCallback() {
    Promise.all([
        loadScript(this, zipcelx+ '/zipcelx-master/lib/module.js')
    ]).then(() => {
        loadScript(this, zipcelx+ '/zipcelx-master/lib/standalone.js')
    }).then(() => {
        loadScript(this, zipcelx+ '/zipcelx-master/lib/legacy.js')
    }).then(() => {
        zipcelx({
            filename: 'general-ledger-Q1',
        sheet: {
          data: [
            [{
              value: 'Income - Webshop',
              type: 'string'
            }, {
              value: 1000,
              type: 'number'
            }]
          ]
        }})
    }).catch( e =>{
        console.log('Exception:'+e);
    });

}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant