['!cols'] is undefined
See original GitHub issueI am trying to modify XLS files and keeping the visibility values for columns.
I am using ^0.14.3 inside a web worker with Angular ^8.0.0.
However, whenever I read an XLS file, ['!cols']
is not defined in the worksheet object, even though there are hidden columns in the file. So it is impossible for me to retrieve the ‘hidden’ values for the columns.
Am I missing something? !ref
and !margins
are there.
Here’s the web worker code:
/// <reference lib="webworker" />
declare function importScripts(...urls: string[]): void;
declare function postMessage(message: any): any;
declare const XLSX: any;
addEventListener('message', ({ data }) => {
let str = `${data.window.protocol}//path/to/xlsx.full.min.js`;
importScripts(str);
const xls = XLSX.read(data.file, { type: 'array' });
const sheet = xls.Sheets[xls.SheetNames[0]];
console.log(sheet['!cols']); // returns undefined
// (...)
postMessage(xls);
});
Below function sits in a service and spins up a Worker
for every file from a FileList
loadXLS(files: FileList, values: {}, loc: string) {
Array.from(files).forEach(file => {
const worker = new Worker('../excel.worker.ts', {
type: 'module'
});
const reader: FileReader = new FileReader();
reader.readAsArrayBuffer(file);
reader.onloadend = (e: any) => {
worker.onmessage = ({ data }) => {
XLSX.writeFile(data, file.name);
};
worker.postMessage({ file: new Uint8Array(e.target.result), locale: loc, val: values, window: this.inputWindow });
};
});
}
Here’s a branch that provides an implementation example: https://github.com/fripso/kupshred/tree/missingcols
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
['!cols'] is undefined · Issue #1560 · SheetJS ...
I am trying to modify XLS files and keeping the visibility values for columns. I am using ^0.14.3 inside a web worker with...
Read more >Sheetjs `!rows` (and `!cols`) property not existing on newly ...
it returns undefined . Inspecting ws shows it also doesn't hold that property. How would I access the row properties (and set for...
Read more >How to Handle "undefined columns selected" in R
undefined columns selected. This error occurs when you try to select a subset of a data frame and forget to add a comma....
Read more >How to deal with error “undefined columns selected when ...
The error “undefined columns selected when subsetting data frame” means that R does not understand the column that you want to use while ......
Read more >Export to Excel - 'Cols' is null or undefined
Hi, I'm hoping someone out there can help me... I've got a radgrid and in the <CommandItemTemplate> I have a button with CommandName="E......
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
@fripso for XLSX format,
cellStyles: true
must be set to extract column metadata.@cjl-df “range is wrong” is almost always an issue in the file. XLS has a Dimension record and XLSX also has a way of specifying range, so the reader will set the range based on what that file reports (even if cells exist outside). We’d be glad to take a look at a sample file if you can share one
but how to decide the font style