Skip to content

Update cheet-js (js-xlsx) to last version #19

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lbAntoine
Copy link

I've encountered problems when using the package while running an updated version of js-xlsx for file export purposes. I opted to fork the project and just made a minor change to the version of the package.

Before

// There is code before, I'll just use the try and catch to make it shorter
try {
  var workbook = XLS.read(data, { type: 'binary' });

  if (attrs.onread) {
    var handleRead = scope[attrs.onread];
    if (typeof handleRead === "function") {
      handleRead(workbook);
    }
  }
} catch (e) {
  if (attrs.onerror) {
    var handleError = scope[attrs.onerror];
    if (typeof handleError === "function") {
      handleError(e);
    }
  }
}

After

try {
  var workbook = XLSX.read(data, { type: 'binary' }); // The global changed to XLSX on newer versions

  if (attrs.onread) {
    var handleRead = scope[attrs.onread];
    if (typeof handleRead === "function") {
      handleRead(workbook);
    }
  }
} catch (e) {
  if (attrs.onerror) {
    var handleError = scope[attrs.onerror];
    if (typeof handleError === "function") {
      handleError(e);
    }
  }
}

This seemed to fix the problem I had and let me run both this package and the original js-xlsx package for other purposes. Hoping this could help someone else.

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

Successfully merging this pull request may close these issues.

1 participant