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

m-ketan picture m-ketan  路  3Comments

eyalcohen4 picture eyalcohen4  路  3Comments

magtuan picture magtuan  路  3Comments

HachimDev picture HachimDev  路  3Comments

dullin picture dullin  路  3Comments