There doesn't appear to be uniformity when trying to read the text value of a cell. I get either a string or object, meaning I have to check the type of each cell's value first and act accordingly.
Row: 125
*[CHI - 032] The team member recognizes all loyalty programme members with a warm comment of appreciation (e.g.: "Thank you for your loyalty / trust").
Typeof: string
{ richText:
[ { text: '*[CHI - 032] O membro da equipe cumprimenta todos os associados do programa de fidelidade com um coment谩rio caloroso (por exemplo:' },
{ font: [Object],
text: ' "Obrigado por sua fidelidade/confian莽a.").' } ] }
Typeof: object
(node:2350) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: worksheet.getRow(...).getCell(...).value.replace is not a function
console.log(worksheet.getRow(row).getCell(1).value);
console.log(`Typeof: ${typeof worksheet.getRow(row).getCell(1).value)});
let original = worksheet.getRow(row).getCell(1).value.replace(/\r/g, '').trim();
console.log(worksheet.getRow(row).getCell(1).value);
console.log(`Typeof: ${typeof worksheet.getRow(row).getCell(1).value)});
let translation = worksheet.getRow(row).getCell(column).value.replace(/\r/g, '').trim();
Use `getCell(1).text" instead?
The value property is intended to return something most useful for the type of value stored in the cell. For text it will be string, for numbers it will be JavaScript numbers, dates are the JS Date, etc. For more complicated value types (e.g. hypertexts, rich strings, error values, etc) the only sensible representation is an object.
As Rycochet said, if you only ever want the text value, you can access the .text property and the cell will try to return the most sensible text representation.
Ok, thank you for clearing that up. I didn't see it in the readme anywhere.
Most helpful comment
Ok, thank you for clearing that up. I didn't see it in the readme anywhere.