SheetJS: Convert complete ExcelSHEET from Text to number

let myWorkbookSheet = workbook.Sheets["measurements"];
let rangeOfValueContainingCells = XLSX.utils.decode_range(myWorkbookSheet['!ref']);

/* change cell format of range. Remember: s = start, e = end; r = row, c = column. */
for(let i = rangeOfValueContainingCells.s.r; i <= rangeOfValueContainingCells.e.r; ++i) {
    for(let j = rangeOfValueContainingCells.s.c; j <= rangeOfValueContainingCells.e.c; ++j) {
        let cellAddress = XLSX.utils.encode_cell({r:i, c:j}); // encode_cell(...) transforms the index-notation (of Javascript) to the A1-notation (standard-notation in Excel, e.g. C3 or D7 ...)
        let cell = myWorkbookSheet[cellAddress];
        // cell.t is the type-property of the cell: b -> boolean, e -> error, n -> number, d -> date, s -> text, z -> stub
        cell.t = 'n';
    }
}

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.