WPS表格加载项续写内容四
书接上回:WPS表格加载项续写内容三
main.js内容继续:
function AutoSave(){
setTimeout(AutoSave,wps.PluginStorage.getItem("remainingtime")*1000)
var newdate = new Date();
if(wps.PluginStorage.getItem("IsAutoSave")){
//wps.Application.SendKeys("^s");
Application.CommandBars.ExecuteMso("FileSave");
console.log(newdate.toLocaleString() + "定时保存启动");
}else{
console.log(newdate.toLocaleString() +"定时保存未启动");
}
}
function setinteriorcolor(Target){
var activeCell = Target.Cells.Item(1, 1);
var rowRange = wps.Application.Rows.Item(activeCell.Row);
var colRange = wps.Application.Columns.Item(activeCell.Column);
var color = wps.PluginStorage.getItem("interiorcolor");
wps.Application.Cells.Interior.ColorIndex = wps.Enum.xlNone //是否全部清空?
var issetrow = wps.PluginStorage.getItem("cBox_rowinterior");
var issetcolumn = wps.PluginStorage.getItem("cBox_columninterior");
console.log("issetcolumn"+issetcolumn+",issetrow"+issetrow)
if(issetrow){
rowRange.Interior.Color = parseInt(color.r.toString(16).padStart(2,'0')+color.g.toString(16).padStart(2,'0')+color.b.toString(16).padStart(2,'0'),16);
}else{
//color.r = 255;
//color.g = 255;
//color.b = 255;
rowRange.Interior.Color = wps.Enum.xlNone;
}
if(issetcolumn){
colRange.Interior.Color = parseInt(color.r.toString(16).padStart(2,'0')+color.g.toString(16).padStart(2,'0')+color.b.toString(16).padStart(2,'0'),16) ;
}else{
//color.r = 255;
//color.g = 255;
//color.b = 255;
colRange.Interior.Color = wps.Enum.xlNone; //16777215; //xlColorIndexNone ; xlColorIndexAutomatic;
}
//
}
水平有限,代码可能有不完善或改进的逻辑,请指教。