最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论