javascript - ExcelJS - How to get the current values of a dropdown of a cell - Stack Overflow

I'm populating an existing Excel file using ExcelJS.Setting the value directly, without re-adding

I'm populating an existing Excel file using ExcelJS.

Setting the value directly, without re-adding the dataValidation wipes out the dropdown. It's necessary to re-add the validations again using the code below (for example):

const workbook = new ExcelJS.Workbook();
await workbook.xlsx.load(buffer);
const targetSheet = workbook.worksheets[1];
let row = targetSheet.getRow(rowNumber); // Target row
cell = row.getCell(4); // Target cell
cell.dataValidation = {
      type: 'list',
      allowBlank: false,
      formulae: ['"Option1,Option2,Option3"']
};

Now, I also need to read the existing dropdown values before setting the new value but using cell.dataValidation does not work to read the current dataValidation, but strangely it works to write them.

How to read the existing dataValidation of a specific cell using ExcelJS?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745156142a4614132.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信