Exceljs数据验证列表导致Excel女士出错
我使用exceljs节点模块并添加下拉数据验证
worksheet.getCell(cell).dataValidation = {
type: 'list',
allowBlank: true,
formulae: ['"One,Two,Three,Four"'],
showErrorMessage: true,
errorStyle: 'error',
errorTitle: 'Error',
error: 'Value must be in the list'
};
文件已成功生成。但是只能使用Libre Office打开。与Office女士打开文件将导致以下错误:
Excel completed file level validation and repair.
Some parts of this workbook mau have been repaired or discarded.
Repaired Part: /xl/worksheets/sheet1.xml part.
如何解决此问题?
回答如下:反转数据验证公式中的引号。看起来它仅支持并识别theother一个。
worksheet.getCell(cell).dataValidation=
{
type : "list",
allowBlank : true,
formulae : ["'One,Two,Three,Four'"],//<--------------------------------Right there
showErrorMessage : true,
errorStyle : "error",
errorTitle : "Error",
error : "Value must be in the list"
}
};