背景颜色 telerik 网格到 excel
background color telerik grid to excel
是否可以用另一种方式或至少像这样但有更多颜色选项来做到这一点?
这很好用,可以满足我的需要,但我还需要更多颜色选项,这是代码
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];"; }
}
}
}
答案很简单,我只需要替换 if (row.cells[colIndex].value == "Weekend-") {row.cells[colIndex].format = "[Blue];";}
和
if (row.cells[colIndex].value == "Weekend-") {row.cells[colIndex].background = "#1E90FF";}
更改单元格的背景
是否可以用另一种方式或至少像这样但有更多颜色选项来做到这一点?
这很好用,可以满足我的需要,但我还需要更多颜色选项,这是代码
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];"; }
}
}
}
答案很简单,我只需要替换 if (row.cells[colIndex].value == "Weekend-") {row.cells[colIndex].format = "[Blue];";}
和
if (row.cells[colIndex].value == "Weekend-") {row.cells[colIndex].background = "#1E90FF";}
更改单元格的背景