Sheetjs: Hiding columns

Created on 5 Feb 2018  路  4Comments  路  Source: SheetJS/sheetjs

How would you hide a column?

I've trying 'playing' with the width of columns, but whenever there's text, the column is being displayed...

Most helpful comment

Set the hidden column property. Here is an example fiddle

var AOA = [
  ["a","b","c"],
  [1,2,3],
  [4,5,6]
];

var ws = XLSX.utils.aoa_to_sheet(AOA);
console.log(ws);

/* hide second column */
ws['!cols'] = [];
ws['!cols'][1] = { hidden: true };

/* hide first row */
ws['!rows'] = [];
ws['!rows'][0] = { hidden: true };

/* generate file */
var wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "TestSheet");
XLSX.writeFile(wb, "issue983.xlsx");

All 4 comments

not relevant

Set the hidden column property. Here is an example fiddle

var AOA = [
  ["a","b","c"],
  [1,2,3],
  [4,5,6]
];

var ws = XLSX.utils.aoa_to_sheet(AOA);
console.log(ws);

/* hide second column */
ws['!cols'] = [];
ws['!cols'][1] = { hidden: true };

/* hide first row */
ws['!rows'] = [];
ws['!rows'][0] = { hidden: true };

/* generate file */
var wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "TestSheet");
XLSX.writeFile(wb, "issue983.xlsx");

var wb = XLSX.utils.table_to_book(elt, {sheet:"Sheet JS",display:true});

works for me, ignore all th in 'display:none'

var wb = XLSX.utils.table_to_book(elt, {sheet:"Sheet JS",display:true});

works for me, ignore all th in 'display:none'
it's work thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thomasledoux1 picture thomasledoux1  路  3Comments

lxzhh picture lxzhh  路  3Comments

jamespan0 picture jamespan0  路  3Comments

happy0088 picture happy0088  路  3Comments

Alex0007 picture Alex0007  路  3Comments