.net dataexcel 脚本公式 函数源码
创始人
2024-12-26 08:38:44
0

示例如:

ScriptExec(""sum(1, 2, 3, 4)"") 结果等于10

using Feng.Excel.Builder; using Feng.Excel.Collections; using Feng.Excel.Interfaces; using Feng.Script.CBEexpress; using Feng.Script.Method; using System; using System.Collections.Generic; using System.Drawing;  namespace Feng.Excel.Script {     [Serializable]     public class ScriptFunctionContainer : DataExcelMethodContainer     {          public const string Function_Name = "DataExcelScript";         public const string Function_Description = "脚本函数";         public override string Name         {             get { return Function_Name; }          }         public override string Description         {             get { return Function_Description; }         }          public ScriptFunctionContainer()         {             BaseMethod model = null;              model = new BaseMethod();             model.Name = "ScriptExec";             model.Description = "执行脚本";             model.Eg = @"=ScriptExec(""sum(1, 2, 3, 4)"") 结果等于10";             model.Function = ScriptExec;             MethodList.Add(model);              model = new BaseMethod();             model.Name = "ScriptIF";             model.Description = "第一参数为True返回第二个参数,否则返加第三个参数";             model.Eg = @"ScriptIF(1>2,10,30)结果等于30";             model.Function = ScriptIF;             MethodList.Add(model);              model = new BaseMethod();             model.Name = "ScriptIsNull";             model.Description = "第一参数为null返回第二个参数,否则返加第一个参数";             model.Eg = @"ScriptIsNull(null,1)";             model.Function = ScriptIsNull;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptArg";             model.Description = @"获取或设置参数 ScriptArg(""argname"")";             model.Eg = @"ScriptArg(""argname"")";             model.Function = ScriptArg;             MethodList.Add(model);              model = new BaseMethod();             model.Name = "ScriptExecG";             model.Description = @"在传第一个参数表格上执行脚本 ScriptExecG(grid)";             model.Eg = @"ScriptExecG(grid)";             model.Function = ScriptExecG;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptSaveContext";             model.Description = @"保存当前执行上下文 ScriptSaveContext()";             model.Eg = @"var context=ScriptSaveContext()";             model.Function = ScriptSaveContext;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptReStoreContext";             model.Description = @"还原当前上下文 ScriptReStoreContext(context)";             model.Eg = @"ScriptReStoreContext(context)";             model.Function = ScriptReStoreContext;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptSwitchContext";             model.Description = @"切换当前上下文 ScriptSwitchContext(grid,cell)";             model.Eg = @"ScriptSwitchContext(grid,cell)";             model.Function = ScriptSwitchContext;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptCellValueChanged";             model.Description = @"获取或设置单元格值变化时脚本 ScriptCellValueChanged(cell,script)";             model.Eg = @"ScriptCellValueChanged(cell,script)";             model.Function = ScriptCellValueChanged;             MethodList.Add(model);              model = new BaseMethod();             model.Name = "ScriptCellClick";             model.Description = @"获取或设置单元格单击时脚本 ScriptCellClick(cell,script)";             model.Eg = @"ScriptCellClick(cell,script)";             model.Function = ScriptCellClick;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptCellDoubleClick";             model.Description = @"获取或设置单元格双击时脚本 ScriptCellDoubleClick(cell,script)";             model.Eg = @"ScriptCellDoubleClick(cell,script)";             model.Function = ScriptCellDoubleClick;             MethodList.Add(model);              model = new BaseMethod();             model.Name = "ScriptCellKeyDown";             model.Description = @"获取或设置单元格键盘按下时脚本 ScriptCellKeyDown(cell,script)";             model.Eg = @"ScriptCellKeyDown(cell,script)";             model.Function = ScriptCellKeyDown;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptCellKeyUp";             model.Description = @"获取或设置单元格键盘抬起时脚本 ScriptCellKeyUp(cell,script)";             model.Eg = @"ScriptCellKeyUp(cell,script)";             model.Function = ScriptCellKeyUp;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptGridEndEdit";             model.Description = @"获取或设置表格结束编辑时脚本 ScriptGridEndEdit(grid,script)";             model.Eg = @"ScriptGridEndEdit(grid,script)";             model.Function = ScriptGridEndEdit;             MethodList.Add(model);              model = new BaseMethod();             model.Name = "ScriptGridLoadCompleted";             model.Description = @"获取或设置表格加载结束时脚本 ScriptGridLoadCompleted(grid,script)";             model.Eg = @"ScriptGridLoadCompleted(grid,script)";             model.Function = ScriptGridLoadCompleted;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptGridClick";             model.Description = @"获取或设置表格单击脚本 ScriptGridClick(grid,script)";             model.Eg = @"ScriptGridClick(grid,script)";             model.Function = ScriptGridClick;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptGridDoubleClick";             model.Description = @"获取或设置表格双击脚本 ScriptGridDoubleClick(grid,script)";             model.Eg = @"ScriptGridDoubleClick(grid,script)";             model.Function = ScriptGridDoubleClick;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptGridValueChanged";             model.Description = @"获取或设置表格值改变时脚本 ScriptGridValueChanged(grid,script)";             model.Eg = @"ScriptGridValueChanged(grid,script)";             model.Function = ScriptGridValueChanged;             MethodList.Add(model);               model = new BaseMethod();             model.Name = "ScriptGridKeyDown";             model.Description = @"获取或设置表格键按下时脚本 ScriptGridKeyDown(grid,script)";             model.Eg = @"ScriptGridKeyDown(grid,script)";             model.Function = ScriptGridKeyDown;             MethodList.Add(model);              model = new BaseMethod();             model.Name = "ScriptGridKeyUp";             model.Description = @"获取或设置表格键抬起时脚本 ScriptGridKeyUp(grid,script)";             model.Eg = @"ScriptGridKeyUp(grid,script)";             model.Function = ScriptGridKeyUp;             MethodList.Add(model);         }         public virtual object ScriptGridKeyUp(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 DataExcel cell = base.GetArgIndex(1, args) as DataExcel;                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyKeyUp;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyKeyUp = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptGridKeyDown(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 DataExcel cell = base.GetArgIndex(1, args) as DataExcel;                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyKeyDown;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyKeyDown = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptGridValueChanged(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 DataExcel cell = base.GetArgIndex(1, args) as DataExcel;                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyValueChanged;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyValueChanged = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptGridDoubleClick(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 DataExcel cell = base.GetArgIndex(1, args) as DataExcel;                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyDoubleClick;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyDoubleClick = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptGridClick(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 DataExcel cell = base.GetArgIndex(1, args) as DataExcel;                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyClick;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyClick = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptGridLoadCompleted(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 DataExcel cell = base.GetArgIndex(1, args) as DataExcel;                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyDataLoadCompleted;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyDataLoadCompleted = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptFormClosing(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 DataExcel cell = base.GetArgIndex(1, args) as DataExcel;                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyFormClosing;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyFormClosing = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptGridEndEdit(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 DataExcel cell = base.GetArgIndex(1, args) as DataExcel;                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyEndEdit;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyEndEdit = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptCellKeyUp(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 ICell cell = base.GetCell(1, args);                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyOnKeyUp;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyOnKeyUp = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptCellKeyDown(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 ICell cell = base.GetCell(1, args);                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyOnKeyDown;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyOnKeyDown = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptCellDoubleClick(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 ICell cell = base.GetCell(1, args);                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyOnDoubleClick;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyOnDoubleClick = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptCellClick(params object[] args)         {               Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 ICell cell = base.GetCell(1, args);                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyOnClick;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyOnClick = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptCellValueChanged(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 ICell cell = base.GetCell(1, args);                 if (cell == null)                 {                     return Feng.Utils.Constants.Fail;                 }                 if (args.Length == 2)                 {                     return cell.PropertyOnCellValueChanged;                 }                 string script = base.GetTextValue(2, args);                 cell.PropertyOnCellValueChanged = script;                 return Feng.Utils.Constants.OK;             }             return null;         }          public virtual object ScriptArg(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 string key = base.GetTextValue(1, args);                 if (args.Length == 3)                 {                     object value = base.GetArgIndex(2, args);                     proxy.SetKeyValue(key, value);                     return Feng.Utils.Constants.OK;                 }                 return proxy.GetKeyValue(key);             }             return null;         }          public virtual object ScriptIsNull(params object[] args)         {             if (args.Length > 1)             {                 object value1 = args[1];                 object value2 = args[2];                 if (value1 == null)                 {                     return value2;                 }                 else                 {                     return value1;                 }             }             return null;         }          public virtual object ScriptIF(params object[] args)         {             if (args.Length > 2)             {                 object value1 = args[1];                 object value2 = args[2];                 object value3 = args[3];                 bool res = Feng.Utils.ConvertHelper.ToBoolean(value1);                 if (res)                 {                     return value2;                 }                 else                 {                     return value3;                 }             }             return null;         }          public virtual object ScriptExec(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 string txt = base.GetTextValue(1, args);                 int len = args.Length - 2;                 if (len > 0)                 {                     object[] values = new object[len];                     for (int i = 0; i < len; i++)                     {                         values[i] = args[i + 2];                     }                     return ScriptBuilder.Exec(proxy.Grid, proxy.CurrentCell, txt, values);                 }                 return ScriptBuilder.Exec(proxy.Grid, proxy.CurrentCell, txt);             }             return null;         }          public virtual object ScriptExecG(params object[] args)         {             DataExcel grid = base.GetArgIndex(1, args) as DataExcel;             string txt = base.GetTextValue(2, args);             int len = args.Length - 3;             if (len > 0)             {                 object[] values = new object[len];                 for (int i = 0; i < len; i++)                 {                     values[i] = args[i + 3];                 }                 return ScriptBuilder.Exec(grid, null, txt, values);             }             return ScriptBuilder.Exec(grid, null, txt);          }          public virtual object ScriptSaveContext(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 Feng.Collections.HashtableEx scriptContext = new Feng.Collections.HashtableEx();                 scriptContext.Add("Grid", proxy.Grid);                 scriptContext.Add("Cell", proxy.CurrentCell);                 return scriptContext;             }             return null;         }          public virtual object ScriptReStoreContext(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 Feng.Collections.HashtableEx scriptContext = base.GetArgIndex(1, args) as Feng.Collections.HashtableEx;                 if (scriptContext != null)                 {                     proxy.Grid = scriptContext["Grid"] as DataExcel;                     proxy.CurrentCell= scriptContext["Cell"] as ICell;                     return Feng.Utils.Constants.OK;                 }             }             return Feng.Utils.Constants.Fail;         }          public virtual object ScriptSwitchContext(params object[] args)         {             Feng.Excel.Script.DataExcelScriptStmtProxy proxy = args[0] as Feng.Excel.Script.DataExcelScriptStmtProxy;             if (proxy != null)             {                 proxy.Grid = base.GetArgIndex(1, args) as DataExcel;                 proxy.CurrentCell = base.GetArgIndex(2, args) as ICell;                 return Feng.Utils.Constants.OK;              }             return Feng.Utils.Constants.Fail;         }     } } 

相关内容

热门资讯

重大通报,金花房卡如何购买西游... 西游联盟房卡更多详情添加微:33549083、 2、在商城页面中选择房卡选项。 3、根...
IA解析/牛牛房卡官网皇豪互娱... 皇豪互娱是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:【3329006910】或QQ:332900...
正版授权!牛牛充值房卡超游联盟... 您好!微信超游联盟大厅链接获取房卡可以通过以下几种方式购买: 1.微信渠道:(超游联盟)大厅介绍:...
头条推荐!金花微信链接市场价格... 头条推荐!金花微信链接市场价格表九酷大厅/随意玩/房卡是在哪里买的九酷大厅/随意玩是一款非常受欢迎的...
科技实测!微信金花房卡怎么弄海... 微信游戏中心:海贝之城房卡在哪里买打开微信,添加客服微信【88355042】,进入游戏中心或相关小程...
正规平台有哪些,牛牛房卡制作链... 豌豆互娱是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:【3329006910】或QQ:332900...
正规平台有哪些,牛牛房卡代理海... 您好!微信海航大厅大厅链接获取房卡可以通过以下几种方式购买: 1.微信渠道:(海航大厅)大厅介绍:...
我来教你/如何购买金花房卡神盾... 微信游戏中心:神盾大厅/新天道房卡在哪里买打开微信,添加客服微信【88355042】,进入游戏中心或...
我来教你/斗牛房卡充值新天道/... 今 日消息,新天道/皇豪互娱房卡添加微信33549083 苹果今日发布了 iOS 16.1 正式版更...
玩家攻略,金花房卡批发价卡丁互... 玩家攻略,金花房卡批发价卡丁互娱/正规房卡找谁买卡丁互娱是一款非常受欢迎的游戏,咨询房/卡添加微信:...
IA解析/牛牛房卡游戏代理海米... 微信游戏中心:海米大厅房卡在哪里买打开微信,添加客服微信【88355042】,进入游戏中心或相关小程...
玩家攻略,怎么买斗牛房卡朱雀大... 微信游戏中心:朱雀大厅房卡在哪里买打开微信,添加客服微信【88355042】,进入游戏中心或相关小程...
推荐一款!牛牛房卡制作链接海星... 海星大厅房卡更多详情添加微:33549083、 2、在商城页面中选择房卡选项。 3、根...
头条推荐!金花房卡如何购买超游... 头条推荐!金花房卡如何购买超游联盟/房卡购买房间怎么开超游联盟是一款非常受欢迎的游戏,咨询房/卡添加...
我来教你/如何购买金花房卡老神... 微信游戏中心:老神兽/皇豪互众房卡在哪里买打开微信,添加客服微信【88355042】,进入游戏中心或...
正版授权!牛牛房卡出售海豚大厅... 正版授权!牛牛房卡出售海豚大厅/房卡购买房间怎么开Sa9Ix苹果iPhone 17手机即将进入量产阶...
重大通报,如何购买金花房卡龙马... 您好!微信龙马大厅大厅链接获取房卡可以通过以下几种方式购买: 1.微信渠道:(龙马大厅)大厅介绍:...
科技实测!金花房卡官网烛龙大厅... 烛龙大厅/新道游房卡更多详情添加微:33549083、 2、在商城页面中选择房卡选项。 ...
我来教你/金花微信链接市场价格... 我来教你/金花微信链接市场价格表天酷大厅/房卡在哪里购买天酷大厅是一款非常受欢迎的游戏,咨询房/卡添...
ia实测“金花房卡从哪里购买/... 皇豪互娱是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:86909166许多玩家在游戏中会购买房卡来...