Writing file ignore cells in hidden columns #3026

Closed
opened 2023-11-09 10:12:09 +00:00 by grindpride · 3 comments

As you can see - i have cells in hidden column AA in input file
After reading/writng output file have no this cells

import XLSX from 'xlsx'

function run() {
  const workbook = XLSX.readFile('script/input.xlsx')

  XLSX.writeFileAsync('script/output.xlsx', workbook, {}, () => {
    console.log('SUCCESS WRITE')
  })
}

run()

versions

node v20.9.0
xlsx v0.18.5
As you can see - i have cells in hidden column AA in input file After reading/writng output file have no this cells ```js import XLSX from 'xlsx' function run() { const workbook = XLSX.readFile('script/input.xlsx') XLSX.writeFileAsync('script/output.xlsx', workbook, {}, () => { console.log('SUCCESS WRITE') }) } run() ``` versions ``` node v20.9.0 xlsx v0.18.5 ```
Owner

The worksheet range is A1:M5163. There are cells outside of the range.

https://docs.sheetjs.com/docs/miscellany/errors#worksheet-only-includes-one-row-of-data includes a few workarounds. The easiest is to pass the option nodim: true to readFile.

https://docs.sheetjs.com/docs/getting-started/installation/nodejs using the latest version, you can test the following:

import * as XLSX from 'xlsx';
import * as fs from 'fs';
XLSX.set_fs(fs);

function run() {
  const workbook = XLSX.readFile('script/input.xlsx', {nodim: true})

  XLSX.writeFileAsync('script/output.xlsx', workbook, {}, () => {
    console.log('SUCCESS WRITE')
  })
}

run()
The worksheet range is `A1:M5163`. There are cells outside of the range. https://docs.sheetjs.com/docs/miscellany/errors#worksheet-only-includes-one-row-of-data includes a few workarounds. The easiest is to pass the option `nodim: true` to `readFile`. https://docs.sheetjs.com/docs/getting-started/installation/nodejs using the latest version, you can test the following: ```js import * as XLSX from 'xlsx'; import * as fs from 'fs'; XLSX.set_fs(fs); function run() { const workbook = XLSX.readFile('script/input.xlsx', {nodim: true}) XLSX.writeFileAsync('script/output.xlsx', workbook, {}, () => { console.log('SUCCESS WRITE') }) } run() ```
Author

I use xlsx for client and server code in one repo.
Will latest node version work in browser?

I use xlsx for client and server code in one repo. Will latest node version work in browser?
Owner

Yes the installation instructions cover the tarball (appropriate for NodeJS and for front-end deployments using a framework like React or Angular). If you are using the standalone scripts, you can use the standalone build that is included in the tarball or use the CDN scripts as described in https://docs.sheetjs.com/docs/getting-started/installation/standalone

Yes the installation instructions cover the tarball (appropriate for NodeJS and for front-end deployments using a framework like React or Angular). If you are using the standalone scripts, you can use the standalone build that is included in the tarball or use the CDN scripts as described in https://docs.sheetjs.com/docs/getting-started/installation/standalone
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#3026
No description provided.