是否可以通过其他方式执行此操作,或者至少可以使用更多颜色选项?
这很好用,做我需要的但我还需要更多的颜色选项,这里是代码
function excelExport(e) {
var sheet = e.workbook.sheets[0];
for (var rowIndex = 1; rowIndex < sheet.rows.length; rowIndex++) {
var row = sheet.rows[rowIndex];
for (var colIndex = 0; colIndex < (sheet.columns.length-2); colIndex++) {
if (row.cells[colIndex].value == "Weekend-") {row.cells[colIndex].format = "[Blue];";}
if (row.cells[colIndex].value == "Vacation Day-") { row.cells[colIndex].format = "[Yellow];"; }
if (row.cells[colIndex].value == "Holiday-") { row.cells[colIndex].format = "[Green];"; }
if (row.cells[colIndex].value == "Critical Task-") { row.cells[colIndex].format = "[Red];"; }
}
}
}
答案 0 :(得分:0)
答案很简单,我只需要替换if (row.cells[colIndex].value == "Weekend-") {row.cells[colIndex].format = "[Blue];";}
与
if (row.cells[colIndex].value == "Weekend-") {row.cells[colIndex].background = "#1E90FF";}
更改单元格的背景