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