-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get the header column from excel #214
Comments
@kalai7890 If you just want to pull the header row, the easiest way is to just walk the cells in the first row:
For simple access patterns, it may be easier to work with an array of arrays. See #212 (comment) for an example of working with the sheet_to_json utility function |
what is range.s.c and range.e.c ? what is the difference? |
It's discussed a bit in the README: the decoded range is an object where For example, for the range reference The mnemonic here is: |
you are brilliant!!! thank you so much |
Hello sir, |
I am using Javascript this is my simple code. oReq.onload = function(e) { /* Call XLSX */ //HOW I COUNT NUMBER OF ROWS AND COLUMN'S WHICH ARE NOT EMPTY oReq.send(); |
@SheetJSDev Thank function is a life saver. Thank you! |
hello, I want to read particular |
@SheetJSDev when I use the function. It returns me "!ref" undefined |
Hi everyone,
But today I upgraded XLSX to version 0.12.3, and now there is an error saying "Property 'format_cell' does not exist on type 'XLSX$Utils" Can you help me, please? Is it there a new function to replace 'format_cell'? |
@victorj2307 It's available in the JS module but currently isn't in the TS definition. If you would like to submit a PR, the type definitions are in decode_range(range: string): Range;
+ /** Format cell */
+ format_cell(cell: CellObject, v?: any, opts?: any): string;
+
/* --- General Utilities --- */
|
Hi @SheetJSDev, thanks for your help. I used a casting to any to avoid TS check. I'd appreciate if you make the change and it will be available in a future version. This is what I did:
Thanks in advance. |
@kalai7890 I found an easier solution using regex. function getSheetHeaders(sheet: WorkSheet) {
const headerRegex = new RegExp('^([A-Za-z]+)1=\'(.*)$');
const cells = XLSX.utils.sheet_to_formulae(sheet);
return cells.filter(item => headerRegex.test(item)).map(item => item.split("='")[1]);
} |
This thing worked for me:
|
Hi ,
I am reading excel file through js-xlsx. my requirement is to read the the first headings row alone,
now i am doing this by
var columns = XLSX.utils.decode_range(workSheet['!ref']).e.c + 1;
for (z in workSheet) {
if(z[0] === '!') continue;
if(rowIndex == 0){
excelColumns[columnIndex] = (JSON.stringify(workSheet[z].v)).replace (/"/g,"");
}
else break;
columnIndex++;
if(columns == columnIndex){
rowIndex++;
}.
but this has some issues while reading the excel if the number of columns in the heading is less than number of columns in the remaining data row for this logic.
Is there any way to do this with js-xlsx library defined function to read the heading of excel.Any help will be much appreciated.
heading here i refer to the first line of the document.
The text was updated successfully, but these errors were encountered: