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.

workbook.xlsx.writeBuffer() silently breaks since v1.11.0, only in production

See original GitHub issue

I have a hard time believing what is happening to me: After getting error complaints from users I found that exports are silently failing. Only in production. It works fine in dev mode!?

After some debugging I could narrow it down to the await workbook.xlsx.writeBuffer() line in this module of mine, as console.log nr. 5 is the last to appear in production:

import * as ExcelJs from 'exceljs/dist/exceljs.min.js'

import getDataArrayFromExportObjects from './getDataArrayFromExportObjects'

export default async ({ data, store }) => {
  console.log('getXlsxBuffer 1')
  const dataArray = getDataArrayFromExportObjects(data)
  console.log('getXlsxBuffer 2', { dataArray })
  const numberOfColumns =
    dataArray && dataArray[0] && dataArray[0].length ? dataArray[0].length : 0
  const workbook = new ExcelJs.Workbook()
  console.log('getXlsxBuffer 3', { workbook })
  const worksheet = workbook.addWorksheet('Daten', {
    views: [
      {
        state: 'frozen',
        xSplit: 0,
        ySplit: 1,
      },
    ],
    autoFilter: {
      from: {
        row: 1,
        column: 1,
      },
      to: {
        row: 1,
        column: numberOfColumns,
      },
    },
  })
  worksheet.addRows(dataArray)
  worksheet.getRow(1).fill = {
    type: 'gradient',
    gradient: 'angle',
    degree: 0,
    stops: [
      { position: 0, color: { argb: 'FFD3D3D3' } },
      { position: 1, color: { argb: 'FFD3D3D3' } },
    ],
  }
  worksheet.getRow(1).font = {
    bold: true,
  }
  worksheet.getRow(1).border = {
    bottom: {
      style: 'thin',
    },
  }
  console.log('getXlsxBuffer 4')
  let buffer
  try {
    console.log('getXlsxBuffer 5')
    buffer = await workbook.xlsx.writeBuffer()
    console.log('getXlsxBuffer 6')
  } catch (error) {
    console.log('getXlsxBuffer, error:', error)
    return store.enqueNotification({
      message: error.message,
      options: {
        variant: 'error',
      },
    })
  }
  console.log('getXlsxBuffer 7', { buffer })
  return buffer
}

I then started rolling back versions and found that it works fine in v1.10.0 in production.

Some more info:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:33 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
Sennesephcommented, Jul 10, 2019

I’m also having this problem with this library in Angular+CLI (8.2.0-next.0 atm). I tried switching to 1.10.0, but I have the same problem.

I think it’s a combination of Angular CLI’s build process being broken and some quirk with this library. Like the Promise library used by ExcelJS has been replaced by some kind of empty placeholder function.

Is there anything I can do to research this more on my own? I’d also like to help get ExcelJS into a more modern module, one that can be tree-shaken by webpack.

Edit: Nevermind, colleague had checked-in a bad package.json, was using 1.13.0 instead.

4reactions
barbalexcommented, Jun 25, 2019

@Galeups The closed issue is the one stating that exports did not work in our project. Rolling back exceljs solved that.

The issue with exceljs remains, so this issue should remain open until the issue is resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

workbook.xlsx.writeBuffer() is working fine in Dev but not ...
I am using ExcelJs Lib(1.12.0) inside angular 6 but this Lib is wokring fine in dev but not in production its failing at...
Read more >
pkg_desc_index « metadata - repo/sync/gentoo.git
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23...
Read more >
Beginner's Guide to exceljs. Handling spreadsheet data in ...
Creating worksheet; Handling headers and footers; Setting frozen or split views; Setting auto filters; Data manipulation on rows and 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