sheetjs/xlsx-tests.ts
Wolfgang Faust 8385d5c889 xlsx: Linter: Require interfaces to start with 'I'
The default rule for DT is that they're *not*,
but changing that now would break existing usages of the xlsx typings.
2017-05-13 13:05:21 -04:00

26 lines
650 B
TypeScript

import xlsx = require('xlsx');
const options: xlsx.IParsingOptions = {
cellDates: true
};
const workbook = xlsx.readFile('test.xlsx', options);
const otherworkbook = xlsx.readFile('test.xlsx', {type: 'file'});
console.log(workbook.Props.Author);
const firstsheet: string = workbook.SheetNames[0];
const firstworksheet = workbook.Sheets[firstsheet];
console.log(firstworksheet["A1"]);
interface ITester {
name: string;
age: number;
}
const jsonvalues: ITester[] = xlsx.utils.sheet_to_json<ITester>(firstworksheet);
const csv = xlsx.utils.sheet_to_csv(firstworksheet);
const formulae = xlsx.utils.sheet_to_formulae(firstworksheet);