当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript utils.json_to_sheet方法代码示例

本文整理汇总了TypeScript中xlsx.utils.json_to_sheet方法的典型用法代码示例。如果您正苦于以下问题:TypeScript utils.json_to_sheet方法的具体用法?TypeScript utils.json_to_sheet怎么用?TypeScript utils.json_to_sheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xlsx.utils的用法示例。


在下文中一共展示了utils.json_to_sheet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: exportReport

  ///export report 3 sheets
  public exportReport(json, excelFileName: string): void {
    let worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json[0]);
    let worksheet1: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json[1]);
    let worksheet2: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json[2]);


    // tslint:disable-next-line:max-line-length
    let workbook: XLSX.WorkBook = { Sheets: { 'report1': worksheet, 'report2': worksheet1 , 'report3': worksheet2}, SheetNames: ['report1','report2', 'report3'] };
    let excelBuffer: any = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
    this.saveAsExcelFile(excelBuffer, excelFileName);
  }
开发者ID:Sysarksteam,项目名称:RecipeManagementUI,代码行数:12,代码来源:excel.service.ts

示例2: exportAsExcelFile

 public exportAsExcelFile(json: any[], excelFileName: string): void {
   
   const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json);
   console.log('worksheet',worksheet);
   const workbook: XLSX.WorkBook = { Sheets: { 'data': worksheet }, SheetNames: ['data'] };
   const excelBuffer: any = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
   //const excelBuffer: any = XLSX.write(workbook, { bookType: 'xlsx', type: 'buffer' });
   this.saveAsExcelFile(excelBuffer, excelFileName);
 }
开发者ID:abuabbas1991365,项目名称:cashgift,代码行数:9,代码来源:excel.service.ts

示例3:

    [2,3,4,5,6,7,8]
], {
	dateNF: "yyyy-mm-dd",
	cellDates: true,
	sheetStubs: false
});

const ws1b = XLSX.utils.aoa_to_sheet([ "SheetJS".split("") ]);
XLSX.utils.sheet_add_aoa(ws1b, [[1,2], [2,3], [3,4]], {origin: "A2"});
XLSX.utils.sheet_add_aoa(ws1b, [[5,6,7], [6,7,8], [7,8,9]], {origin:{r:1, c:4}});
XLSX.utils.sheet_add_aoa(ws1b, [[4,5,6,7,8,9,0]], {origin: -1});

const ws2 = XLSX.utils.json_to_sheet([
    {S:1,h:2,e:3,e_1:4,t:5,J:6,S_1:7},
    {S:2,h:3,e:4,e_1:5,t:6,J:7,S_1:8}
], {
	header:["S","h","e","e_1","t","J","S_1"],
	cellDates: true,
	dateNF: "yyyy-mm-dd"
});

const ws2b = XLSX.utils.json_to_sheet([
  { A:"S", B:"h", C:"e", D:"e", E:"t", F:"J", G:"S" },
  { A: 1,  B: 2,  C: 3,  D: 4,  E: 5,  F: 6,  G: 7  },
  { A: 2,  B: 3,  C: 4,  D: 5,  E: 6,  F: 7,  G: 8  }
], {header:["A","B","C","D","E","F","G"], skipHeader:true});

const ws2c = XLSX.utils.json_to_sheet([
  { A: "S", B: "h", C: "e", D: "e", E: "t", F: "J", G: "S" }
], {header: ["A", "B", "C", "D", "E", "F", "G"], skipHeader: true});
XLSX.utils.sheet_add_json(ws2c, [
  { A: 1, B: 2 }, { A: 2, B: 3 }, { A: 3, B: 4 }
开发者ID:CareerFairPlus,项目名称:js-xlsx,代码行数:32,代码来源:doc.ts

示例4:

const out3 = XLSX.write(wb3, write_opts);

const ws1 = XLSX.utils.aoa_to_sheet([
    "SheetJS".split(""),
    [1,2,3,4,5,6,7],
    [2,3,4,5,6,7,8]
], {
	dateNF: "yyyy-mm-dd",
	cellDates: true,
	sheetStubs: false
});

const ws2 = XLSX.utils.json_to_sheet([
    {S:1,h:2,e:3,e_1:4,t:5,J:6,S_1:7},
    {S:2,h:3,e:4,e_1:5,t:6,J:7,S_1:8}
], {
	header:["S","h","e","e_1","t","J","S_1"],
	cellDates: true,
	dateNF: "yyyy-mm-dd"
});

const tbl = {}; /* document.getElementById('table'); */
const ws3 = XLSX.utils.table_to_sheet(tbl, {
	raw: true,
	cellDates: true,
	dateNF: "yyyy-mm-dd"
});

const obj1 = XLSX.utils.sheet_to_formulae(ws1);

const str1: string = XLSX.utils.sheet_to_csv(ws2, {
	FS: "\t",
开发者ID:ErikHoeven,项目名称:WisdomAsAService,代码行数:32,代码来源:doc.ts


注:本文中的xlsx.utils.json_to_sheet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。