當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript xlsx.write函數代碼示例

本文整理匯總了TypeScript中xlsx.write函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript write函數的具體用法?TypeScript write怎麽用?TypeScript write使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了write函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: printBalance

	printBalance(data: Balance[]): any {
		
		const wb = new Workbook();
		
		const COLUMNS = [
			{title: 'Institution', att: ['coe', 'institution', 'name']},
			{title: 'Student', att: ['coe', 'student', 'name']},
			{title: 'Expected Commission', att: ['expectedCommission']},
			{title: 'Expected Gts', att: ['expectedGts']},
			{title: 'Total Expected', att: ['expectedAmount']},
			{title: 'Received Amount', att: ['receivedAmount']},
			{title: 'Remaining Amount', att: ['remainingAmount']}
		];
	
		const ws = this.getSheetFromData(COLUMNS, data);
		
		/* add worksheet to workbook */
		const ws_name = 'balance';
		wb.SheetNames.push(ws_name);
		wb.Sheets[ws_name] = ws;
		
		/* write file */
		const wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: true, type: 'binary'});
		return wbout;	
	}
開發者ID:australdev,項目名稱:app,代碼行數:25,代碼來源:xlsx_service.ts

示例2: printPayments

	printPayments(data: Payment[]): any {
		
		const wb = new Workbook();
		
		const COLUMNS = [
			{title: 'Institution', att: ['studyPeriod', 'coe', 'institution', 'name']},
			{title: 'Student', att: ['studyPeriod', 'coe', 'student', 'name']},
			{title: 'Course Fee', att: ['coursePayment']},
			{title: 'Commission (%)', att: ['commPerc']},
			{title: 'Gts', att: ['dataToPrintGts']},
			{title: 'Expected Commission', att: ['expectedComm']},
			{title: 'Expected Value', att: ['expectedValue']},
			{title: 'Due To', att: ['expectedDate'], date: true },
			{title: 'Received Value', att: ['receivedValue']},
			{title: 'Invoice #', att: ['invoice']}
		];
	
		const ws = this.getSheetFromData(COLUMNS, data);
		
		/* add worksheet to workbook */
		const ws_name = 'students';
		wb.SheetNames.push(ws_name);
		wb.Sheets[ws_name] = ws;
		
		/* write file */
		const wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: true, type: 'binary'});
		return wbout;	
	}
開發者ID:australdev,項目名稱:app,代碼行數:28,代碼來源:xlsx_service.ts

示例3: 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

示例4: 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

示例5:

	bookType: "xlsx",
	sheet: "Sheet1",
	compression: false,
	Props: {
		Author: "Someone",
		Company: "SheetJS LLC"
	}
};

const wb1 = XLSX.readFile("sheetjs.xls", read_opts);
XLSX.writeFile(wb1, "sheetjs.new.xlsx", write_opts);

read_opts.type = "binary";
const wb2 = XLSX.read("1,2,3\n4,5,6", read_opts);
write_opts.type = "binary";
const out2 = XLSX.write(wb2, write_opts);

read_opts.type = "buffer";
const wb3 = XLSX.read(fs.readFileSync("sheetjs.xlsx"), read_opts);
write_opts.type = "base64";
const out3 = XLSX.write(wb3, write_opts);
write_opts.type = "array";
const out4 = 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,
開發者ID:CareerFairPlus,項目名稱:js-xlsx,代碼行數:31,代碼來源:doc.ts

示例6:

import * as XLSX from 'xlsx';

console.log(XLSX.version);

const bookType: string = "xlsb";
const fn: string = "sheetjsfbox." + bookType
const sn: string = "SheetJSFBox";
const aoa: any[][] = [ ["Sheet", "JS"], ["Fuse", "Box"], [72, 62] ];


var wb: XLSX.WorkBook = XLSX.utils.book_new();
var ws: XLSX.WorkSheet = XLSX.utils.aoa_to_sheet(aoa);
XLSX.utils.book_append_sheet(wb, ws, sn);

var payload: string = "";
var w2: XLSX.WorkBook;
if(typeof process != 'undefined' && process.versions && process.versions.node) {
	/* server */
	XLSX.writeFile(wb, fn);
	w2 = XLSX.readFile(fn)
} else {
	/* client */
	payload = XLSX.write(wb, {bookType: "xlsb", type:"binary"});
	w2 = XLSX.read(payload, {type:"binary"});
}

var s2: XLSX.WorkSheet = w2.Sheets[sn];
console.log(XLSX.utils.sheet_to_csv(s2));
開發者ID:CareerFairPlus,項目名稱:js-xlsx,代碼行數:28,代碼來源:sheetjs.ts


注:本文中的xlsx.write函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。