【发布时间】:2018-04-03 20:38:34
【问题描述】:
我正在导出带有一些标题值的空 Excel 工作表。在那个 excel 表中,我想为日期字段设置日期格式,如 (mm/dd/yyyy)。如何为该单元格设置指定的格式。
这里我定义了excel表格单元格:
var InstructionSheet = workbook.addWorksheet('Instruction');
InstructionSheet.getCell('A22').value = 'F: Start Date';
InstructionSheet.getCell('A22').font = {
name: 'Calibri',
bold: true
};
worksheet.columns = [
{ header: 'ProjectName', key: 'id', width: 10 },
{ header: 'UniqueID', key: 'name', width: 40 },
{ header: 'Name', key: 'name', width: 40 },
{ header: 'ResourceNames', key: 'name', width: 32 },
{ header: 'Type', key: 'name', width: 32 },
{ header: 'IsBillable', key: 'name', width: 12 },
{ header: 'IsCR', key: 'name', width: 12 },
{ header: 'Duration', key: 'name', width: 25 },
{ header: 'StartDate', key: 'string', width: 25 },
{ header: 'EndDate', key: 'string', width: 25 },
{ header: 'Predecessors', key: 'string', width: 25 },
{ header: 'Phase', key: 'string', width: 25 },
];
worksheet.getCell('I1').font = { // Start Date column
name: 'Calibri',
bold: true
};
我尝试以这种方式设置日期格式。但它不起作用
InstructionSheet.getCell('A22').font = { 名称:'Calibri', 粗体:真实, 日期格式:'mm-dd-yyyy' }; InstructionSheet.getCell('A22','mm-dd-yyyy').value = 'F: 开始日期';
生成excel表格时如何设置日期列的指定日期格式。
提前致谢
【问题讨论】:
标签: angularjs node.js date exceljs npmjs