question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: column.equivalentTo is not a function

See original GitHub issue

Hi,

I have just encoutered this error since yersterday.

Can you please give me the “real reason” of that? What’s happened?

  var exportForApp = function (app_id, callback) {
  var wb = initializeWorkbook();
  var sheet = initializeWorksheet(wb, getSheetTabName());
  var headers = getExportHeaders();

  formService.findByAppWithGift(app_id, function (err, forms) {
    if (err) { callback(true, err); }
    else {
      for (var i in forms) {
        var row = {
          gender: forms[i].gender,
          first_name: forms[i].first_name,
          last_name: forms[i].last_name,
          email: forms[i].email,
          optin: forms[i].optin,
          prize: forms[i].gift_name
        };
        sheet.addRow(row);
      }

      var filePath = getExportFileName();
      var streamFile = fs.createWriteStream(filePath);
      streamFile.end();

      wb.xlsx.writeFile(filePath)
      .then(function() {
        callback(false, filePath);
      })
      .catch(function (err) {
        console.log(err);
        callback(true, err);
      });
    }
  });
}

// returns the export file name
function getExportFileName () {
  return format("%s/File-export-%s.xlsx", config.admin.exportStoragePath, moment().format(config.admin.exportDateFormat));
}

// returns the headers
function getExportHeaders () {
  return [
    { key: "gender", title: "Civilité" },
    { key: "first_name", title: "Prénom" },
    { key: "last_name", title: "Nom" },
    { key: "email", title: "Email" },
    { key: "optin", title: "Optin newsletter"},
    { key: "prize", title: "Gain" }
  ];
}

// returns the sheet tab name
function getSheetTabName () {
  return "Participants";
}

// intitialize the workbook and return it
function initializeWorkbook () {
  var wb = new xls.Workbook();
  wb.creator = "LOL";
  wb.created = new Date();
  wb.modified = new Date();
  return wb;
}

// initialize the worksheet and return it
function initializeWorksheet (workbook, name) {
  var sheet = workbook.addWorksheet(name);
  var headers = getExportHeaders();

  sheet.properties.outlineLevelCol = headers.length;
  sheet.properties.outlineLevelRow = headers.length > 0 ? 1 : 0;
  sheet.columns = [];

  for (var i in headers) {
    sheet.columns.push({ key: headers[i].key, header: headers[i].title, width: 40, outlineLevel: 1 });
  }

  return sheet;
}```

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

36reactions
kpsuperplanecommented, Aug 17, 2016

@christophedebatz it appears you have to dump the entire columns array into the columns property at once… I was pushing to it inplace before with a for loop… reassigned it into a variable, dumped it in all at once after, and it worked

27reactions
alberttomasiakcommented, Jan 20, 2020

@LVMuser You can’t use worksheet.columns.push(x) .

In order to make this work you can only define the columns once. So, to get it to work define a variable with your columns, add the extra ones afterwards and THEN define the columns on your worksheet:

const sheetColumns = [
  { header: 'name', key: 'name', width: 5 },
  { header: 'age', key: 'age', width: 10 },
];

sheetColumns.push(
  { header: 'gender', key: 'gender', width: 10}
);

worksheet.columns = sheetColumns;

EDIT: atleast I think you can’t use .push(x). Correct me if I’m wrong! Tried it myself but didn’t work, whereas defining it once, like suggested above, works 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

writeFile not woking in exceljs - node.js - Stack Overflow
i am using exceljs and try to write value in a cell but it does not working. However workbook.
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
TypeError: $(...).DataTable is not a function in jQuery
To solve the "$(...).DataTable is not a function" jQuery error, make sure to load the jQuery library before loading the DataTables library.
Read more >
The Worksheet Class — XlsxWriter Documentation
-1: Row or column is out of worksheet bounds. ... NAN and INF are not supported and will raise a TypeError exception unless...
Read more >
pandas.DataFrame.nlargest — pandas 1.5.2 documentation
The columns that are not specified are returned as well, but not used for ordering. This method is equivalent to df.sort_values(columns, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found