2017-05-15 15:48:44 +00:00
|
|
|
import XLSX = require('xlsx');
|
2015-06-03 13:34:42 +00:00
|
|
|
|
2017-05-15 15:48:44 +00:00
|
|
|
const options: XLSX.ParsingOptions = {
|
2017-05-12 21:46:39 +00:00
|
|
|
cellDates: true
|
2015-06-03 13:34:42 +00:00
|
|
|
};
|
|
|
|
|
2017-05-15 15:48:44 +00:00
|
|
|
const workbook = XLSX.readFile('test.xlsx', options);
|
|
|
|
const otherworkbook = XLSX.readFile('test.xlsx', {type: 'file'});
|
2015-06-03 13:34:42 +00:00
|
|
|
|
|
|
|
console.log(workbook.Props.Author);
|
|
|
|
|
2017-05-12 21:46:46 +00:00
|
|
|
const firstsheet: string = workbook.SheetNames[0];
|
2015-06-03 13:34:42 +00:00
|
|
|
|
2017-05-12 21:46:46 +00:00
|
|
|
const firstworksheet = workbook.Sheets[firstsheet];
|
2015-06-03 13:34:42 +00:00
|
|
|
|
|
|
|
console.log(firstworksheet["A1"]);
|
|
|
|
|
2017-05-13 23:37:23 +00:00
|
|
|
interface Tester {
|
2017-05-12 21:46:39 +00:00
|
|
|
name: string;
|
2015-06-03 13:34:42 +00:00
|
|
|
age: number;
|
|
|
|
}
|
|
|
|
|
2017-05-15 15:48:44 +00:00
|
|
|
const jsonvalues: Tester[] = XLSX.utils.sheet_to_json<Tester>(firstworksheet);
|
|
|
|
const csv = XLSX.utils.sheet_to_csv(firstworksheet);
|
|
|
|
const formulae = XLSX.utils.sheet_to_formulae(firstworksheet);
|