光庆
import time.ole
winform.vlist.onDrawCellContent = function(row,col,hdc,r ...
我试了下确实可以,注意删除掉返回值:是否跳过原绘制过程、新bkcolor、新text。均可选。不要跳过原绘制过程,设置false,或者不要返回值。
没想到要在这么早期的绘制阶段,处理数值,那这个想象力就大了,第一次接触这么早期的一个函数
多谢光庆大佬的vlistEx库

完整代码如下
import win.ui;
import com.excel;
import godking.vlistEx;
import console;
import time.ole;
/*DSG{{*/
var mainForm = win.form(text="表格测试";right=438;bottom=487)
mainForm.add(
ImportExcelDate={cls="button";text="读取表格数据";left=13;top=452;right=109;bottom=480;z=2};
vlist={cls="vlistEx";left=9;top=17;right=434;bottom=445;ah=1;aw=1;border=1;db=1;dl=1;dr=1;dt=1;z=1}
)
/*}}*/
var excel,err = com.excel();
excel.alerts = false; //关闭界面提示与屏幕更新
var book = excel.Open( "D:\test.xlsx" );
var sheet = excel.ActiveWorkbook.Sheets(1);
var t ={"序号","水果","重量","开售日期","备注"};
var tt ={};
var tt = sheet.Range("A2:E11").Value2;
//console.dumpTable(tt)
mainForm.vlist.setTable(tt,t/*table.remove(tt)*/,{scale =true,5,5,5,10,10},1);
//console.pause(true)
mainForm.ImportExcelDate.oncommand = function(id,event){
//var tt = sheet.Range("A1:E11").Value2;
console.dumpTable(tt)
mainForm.vlist.setTable(tt,t/*table.remove(tt)*/,{scale =true,5,5,5,10,10},1);
}
mainForm.onClose = function(hwnd,message,wParam,lParam){
excel.Quit(); //退出
}
mainForm.vlist.onDrawCellContent = function(row,col,hdc,rect,bkcolor,text){
/*绘制单元格背景后,开始【绘制单元格有效区域,含第一列中的选择框和树形线】前,触发该事件。
rect为单元格全部区域(含CellRect和padding)。CellRect部分会被有效区域背景遮盖。
返回值:是否跳过原绘制过程、新bkcolor、新text。均可选。
上一事件:onDrawCellBg() 下一事件:onDrawCellRect() */
if col===4 and text return false,null,tostring(time.ole(tonumber(text),"%m月%d日"));
if col===3 and text return false,null,..string.format("%.2f", tonumber(text));
return false,newbklolor,newtext;
}
mainForm.show();
win.loopMessage();