用指定的date格式导出excel表格单元格
我导出空的Excel表单与一些标题值。 在那个excel工作表中,我想为date字段设置date格式,如(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 };
我试图用这种方式设置date格式。 但它不工作
instructionSheet.getCell('A22')。font = {name:'Calibri',bold:true,dateformate:'mm-dd-yyyy'}; instructionSheet.getCell('A22','mm-dd-yyyy')。value ='F:开始date';
如何在生成Excel表单时为date列设置指定的date格式。
提前致谢