Typescript Example
[JavaScript] 纯文本查看 复制代码 function exportExcelHandler() {
interface ExcelOption {
fileName: string;
datas: any;
}
var option: ExcelOption = {
fileName: "excel",
datas: [
{
sheetData: [
['zach', 100, '100.0'],
['zach2',200,'200.0'],
],
},]
}
var toExcel = new ExportJsonExcel(option); //new
toExcel.saveExcel();
}
作者源码自动判定型态部份,如果没特别用string型态,因该是会为数字
[JavaScript] 纯文本查看 复制代码 if (typeof cell.v === "number") cell.t = "n";
else if (typeof cell.v === "boolean") cell.t = "b";
else if (cell.v instanceof Date) {
cell.t = "n";
cell.z = XLSX.SSF._table[14];
cell.v = datenum(cell.v);
} else if (/^hyperlink:/.test(cell.v)) {
cell.l = {
Target: cell.v.replace(/^hyperlink:/, ""),
};
cell.v = cell.v.replace(/^hyperlink:/, "");
} else cell.t = "s"; |