Spread for Window Forms 4.0 技术问题求助
问题描述:
1.自定义公式标注为可序列化 测试代码如下:
[Serializable]
public class CustFun : FunctionInfo
{
public string _Name = String.Empty;
public int _MinArgs = 0;
public int _MaxArgs = 0;
public int _FunType = 0;
public int Row = 0;
public int Col = 0;
public string _SQL = string.Empty;
public override string Name
{
get { return _Name; }
}
public override int MaxArgs
{
get { return _MaxArgs; }
}
public override int MinArgs
{
get { return _MinArgs; }
}
public int FunType
{
get { return _FunType; }
}
public string SQL
{
get { return _SQL; }
}
public override object Evaluate(object[] args)
{
return "Test";
}
2.把自定义公式设置到Grid的当前工作簿中,测试代码如下:
private void button1_Click(object sender, EventArgs e)
{
Gd.ActiveSheet.AutoCalculation = false;
for (int i = 0; i < 100; i++)
{
CustFun a = new CustFun();
a._Name = "abc" + i.ToString();
a._FunType = 2;
a._SQL = "select 1";
//tag.Fun.Add("a" + i.ToString(), a);
Gd.ActiveSheet.AddCustomFunction(a);
Gd.ActiveSheet.SetFormula(1, i, a._Name+"()");
}
Gd.Save("C:\\def.xml", true);
}
}
3.加载模扳文件,测试代码如下:
private void button3_Click(object sender, EventArgs e)
{
Gd.Open("C:\\def.xml");
}
4.现象:一加载模板,公式就会自动计算,如果想加载模板后,公式不自动计算,该如何设置?
谢谢! |
|