我想从数据库中取出制定的值赋给cell报表中指定的行和列,因为刚开始不熟悉,所以参考vb下的演示源代码设计,可是无法触发CalcFunc事件,各位大哥帮忙给看看或者提供另外一种思路。谢谢了
解决方案 »
- try,except,finally的用法
- 本人发愿要用DELPHI做一个视频压缩-实时网络传输-观看的程序,请问需要什么东东?
- 请问为什么结果是负的呢????
- 急求局域网内点对点的文件传输代码,,(socket)
- 只要你开发的软件和数据库打交道,统统3000元开发费用以内,单机版的超低价开发
- ACCESS2000的数据库压缩函数CompactDatabase只能压缩整理数据库,如果想修复数据库用什么方法或函数呢?
- 关于Midas发布的问题:在我的机器上运行正常,在其他的电脑上就说什么ole错误(我用installShield自动搜索过dll..)请问到底应该怎样配置?
- 关于程序执行DTS包文件出现"执行已被用户取消"的问题,江湖救急阿急急!!!!!!!!
- DDE程序最简单的例子!!!麻烦各位看一看
- 程序打包时怎样将BDE一起打包?
- 请教!!大家一个关于图片格式转换的问题!!!
- 想做进销存软件,用mssql数据库,做成网络版,请问用vb好还是delphi好,我知道vb的水晶报表很好,但是做成网络版是不是delphi功能更强一些.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,sys_public,data,unit3,
DB, ADODB, Grids, DBGrids, OleCtrls, CELL50Lib_TLB,
ExtCtrls ;
type
TForm1 = class(TForm)
Cell1: TCell;
Label1: TLabel;
ListBox1: TListBox;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
procedure FormCreate(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Cell1CalcFunc(ASender: TObject; const name: WideString;
rettype, paranum: Integer);
procedure Cell1QueryFuncGuide(ASender: TObject; const name: WideString;
var hasguide: Integer); private
{ Private declarations } procedure definefun();
procedure setfun(index:longint);
function opendb(filedname :string ;row :double):double;
public
{ Public declarations }
end;var
Form1: TForm1;
strarray,HelpArray:array[0..17] of string;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
path:string;begin
path := ExtractFilePath(application.ExeName)+'资产负债表.cll';
cell1.OpenFile(path,'');
definefun();
setfun(1);
cell1.ReDraw;
label2.Caption :=helparray[0];
end;
procedure tform1.definefun();
var
str :string;
begin
//strarray := char(13);
str := '''资产负债表取数函数'' Any 货币资金( str:string,[Double num] )';
str := str + #13#10 + 'BEGIN_HELP'; //#13回车 #10空格
str := str + #13#10 + '货币资金( String str,Double index )';
str := str + #13#10 + '本函数用来获取数据库中的 货币资金 字段的值';
str := str + #13#10 + 'END_HELP';
cell1.DefineFunctions(str);
//showmessage('definefun');
str := '';
str :=str + #13#10 + '货币资金( String str,Double index )';
str := str + #13#10 + '本函数用来获取数据库中的 货币资金 字段的值';
HelpArray[0] := str;
end;
procedure tform1.setfun(index:longint);
var
temp,strtemp:string;
//i:integer;
begin
listbox1.Clear;
strTemp := '货币资金(' + Char(34) + '货币资金' + Chr(34) + ',' + IntToStr(index)+ ')';
Cell1.SetFormula(3,7,0,strtemp);
//showmessage(strtemp);
listbox1.Items.Add(strtemp);
temp := Cell1.CellToLabel(3, 7);
strArray[0] := temp
end;
function tform1.opendb(filedname :string ;row :double):double;
var
index :longint;
i:integer;
begin
with dm1.aq do
begin
SQL.Clear;
SQL.Add('Select * From 资产负债表');
Active := true;
dm1.aq.Open;
end;
for i :=1 to dm1.aq.Fields.Count do
begin
if dm1.aq.fields[i].FieldName = filedname then
begin
index :=i;
exit;
end;
end;
i:=1;
while not dm1.aq.Eof do
begin
if i=row then
begin
opendb := dm1.aq.Fields[index].Value;
exit;
end;
i :=i +1;
end;
dm1.aq.Close;
end;
procedure TForm1.Button7Click(Sender: TObject); //jg :integer;
begin
with dm1.aq do
begin
SQL.Clear;
SQL.Add('Select * From 资产负债表');
Active := true;
dm1.aq.Open;
end;
// dbgrid1.DataSource := dm1.aq;end;procedure TForm1.Button8Click(Sender: TObject);begin
{with Dm1.ADOConnection1 do
begin
Open;
if Connected then
showmessage('连接成功')
else
showmessage('连接失败');
end;}
//para :=0;end;
procedure TForm1.Cell1CalcFunc(ASender: TObject; const name: WideString;
rettype, paranum: Integer);
var
para :longint;
result :double;
begin
showmessage('calcfunc');
result := opendb(cell1.GetFuncStringPara(0,para),cell1.GetFuncDoublePara(1,para));
cell1.SetFuncResult(result,'',0);
end;procedure TForm1.Cell1QueryFuncGuide(ASender: TObject;
const name: WideString; var hasguide: Integer);
begin
If name = '货币资金' Then hasguide := 1;
If name = '短期投资' Then hasguide := 1;
If name = '应收票据' Then hasguide := 1;
If name = '坏帐准备' Then hasguide := 1;
If name = '预付帐款' Then hasguide := 1;
If name = '存货' Then hasguide := 1;
If name = '待处理流动资产净损失' Then hasguide := 1;
If name = '其他流动资产' Then hasguide := 1;
If name = '固定资产原价' Then hasguide := 1;
If name = '在建工程' Then hasguide := 1;
If name = '无形资产' Then hasguide := 1;
If name = '短期借款' Then hasguide := 1;
If name = '应付票据' Then hasguide := 1;
If name = '应付帐款' Then hasguide := 1;
If name = '应付工资' Then hasguide := 1;
If name = '长期借款' Then hasguide := 1;
If name = '长期应付款' Then hasguide := 1;
end;end.