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

Uncaught TypeError: this._factory is not a function #157

Open
ronxbysu opened this issue May 8, 2022 · 2 comments
Open

Uncaught TypeError: this._factory is not a function #157

ronxbysu opened this issue May 8, 2022 · 2 comments

Comments

@ronxbysu
Copy link

ronxbysu commented May 8, 2022

test('xls report file should be created again', async () => {

let values = {
  lastName: 'Тестов',
  firstName: 'Тест',
  middleName: 'Тестович',
};

const XlsxTemplate = require('xlsx-template');

// Load an XLSX file into memory
fs.readFile(path.join(__dirname, 'Book1.xlsx'), function(err, data) {

  // Create a template
  const template = new XlsxTemplate(data);

  // Replacements take place on first sheet
  const sheetNumber = 1;

  // Set up some placeholder values matching the placeholders in the template

  // Perform substitution
  template.substitute(sheetNumber, values);

  // Get binary data
  const generated = template.generate();

  fs.writeFileSync('B1.xlsx', generated, 'binary')

});

});

in Book1.xlsx - one simple string ${lastName} nothing more
then run this test you get:
Uncaught TypeError: this._factory is not a function

@kant2002
Copy link
Collaborator

kant2002 commented May 9, 2022

Couple questions:

  • What's NodeJS version?
  • Are this is new test or existing one?

@kant2002
Copy link
Collaborator

In the offline chat we discover that changing fs.readFile to fs.readFileSync at least unblock the issue. so far there no conclusive reason why issue happens.

I would speculate that when called inside async context this line produce some issues
https://github.com/racker/node-elementtree/blob/master/lib/treebuilder.js#L8

I waiting for smallest @ronxbysu case and will start troubleshooting from this point

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

2 participants