workbook.xlsx.writeBuffer() silently breaks since v1.11.0, only in production
See original GitHub issueI 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:
- my project: https://github.com/barbalex/apf2
- developed on windows 10, up to date
- Gatsby project
- hosted on zeit/now
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:33 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@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.