{"action":"opened","issue":{"url":"https://api.github.com/repos/SheetJS/js-xlsx/issues/1238","repository_url":"https://api.github.com/repos/SheetJS/js-xlsx","labels_url":"https://api.github.com/repos/SheetJS/js-xlsx/issues/1238/labels{/name}","comments_url":"https://api.github.com/repos/SheetJS/js-xlsx/issues/1238/comments","events_url":"https://api.github.com/repos/SheetJS/js-xlsx/issues/1238/events","html_url":"https://github.com/SheetJS/js-xlsx/issues/1238","id":354000140,"node_id":"MDU6SXNzdWUzNTQwMDAxNDA=","number":1238,"title":"Unable to parse file, if first header cell starts with '<' symbol","user":{"login":"GienekGenin","id":27743401,"node_id":"MDQ6VXNlcjI3NzQzNDAx","avatar_url":"https://avatars1.githubusercontent.com/u/27743401?v=4","gravatar_id":"","url":"https://api.github.com/users/GienekGenin","html_url":"https://github.com/GienekGenin","followers_url":"https://api.github.com/users/GienekGenin/followers","following_url":"https://api.github.com/users/GienekGenin/following{/other_user}","gists_url":"https://api.github.com/users/GienekGenin/gists{/gist_id}","starred_url":"https://api.github.com/users/GienekGenin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GienekGenin/subscriptions","organizations_url":"https://api.github.com/users/GienekGenin/orgs","repos_url":"https://api.github.com/users/GienekGenin/repos","events_url":"https://api.github.com/users/GienekGenin/events{/privacy}","received_events_url":"https://api.github.com/users/GienekGenin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-25T09:51:12Z","updated_at":"2018-08-25T09:51:12Z","closed_at":null,"author_association":"NONE","body":"1. CSV file content:\r\n\r\n> <Title,New title.\r\ntext,some text\r\n\r\n2. Code \r\n```\r\n// const workbook = XLSX.readFile(path);\r\nconst parseHeaders = workbook => {\r\n\tconst sheet = workbook.Sheets[workbook.SheetNames[0]];\r\n\tconst range = XLSX.utils.decode_range(sheet['!ref']);\r\n\tlet headers = [];\r\n\tlet C;\r\n\tconst R = range.s.r;\r\n\t/* start in the first row */\r\n\t/* walk every column in the range */\r\n\tlet countBreak = 0;\r\n\tlet buffer = [];\r\n\tfor (C = range.s.c; C <= range.e.c; C += 1) {\r\n\t\tconst cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })];\r\n\t\tlet hdr = 'UNKNOWN'; // <-- replace with your desired default\r\n\t\tif (!cell || cell.v === '' || cell.v === ' ') {\r\n\t\t\tcountBreak += 1;\r\n\t\t\t/* if 3 cell in a row undefined - break */\r\n\t\t\tif (countBreak === 3) {\r\n\t\t\t\treturn renameFiles(headers);\r\n\t\t\t}\r\n\t\t\tbuffer.push(hdr);\r\n\t\t}\r\n\t\t/* find the cell in the first row */\r\n\t\tif (cell && cell.t && cell.v !== '' && cell.v !== ' ') {\r\n\t\t\tcountBreak = 0;\r\n\t\t\thdr = XLSX.utils.format_cell(cell);\r\n\t\t\tif (buffer.length >= 1) {\r\n\t\t\t\theaders = headers.concat(buffer);\r\n\t\t\t}\r\n\t\t\tbuffer = [];\r\n\t\t\theaders.push(hdr);\r\n\t\t}\r\n\t}\r\n\treturn renameFiles(headers);\r\n};\r\n```\r\n3. Error: UnhandledPromiseRejectionWarning: TypeError: Cannot read property '!ref' of undefined\r\n```\r\nworkbook.Sheets // { }\r\nworkbook.SheetNames // [ ]\r\n```\r\n4. Without this ```<``` works just fine\r\n\r\nThanks for your work. This library is truly **```awesome```**."}}
{"actor":{"display_login":"GienekGenin"}}