谁用过cell组件开发报表,进来看看
我想从数据库中取出制定的值赋给cell报表中指定的行和列,因为刚开始不熟悉,所以参考vb下的演示源代码设计,可是无法触发CalcFunc事件,各位大哥帮忙给看看或者提供另外一种思路。谢谢了
问题点数:30、回复次数:3Top
1 楼gl0218(红尘㊣浪子)回复于 2006-03-30 09:50:20 得分 0
附:源代码:
unit Unit1;
interface
uses
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.Top
2 楼gl0218(红尘㊣浪子)回复于 2006-03-31 14:43:48 得分 0
顶起来,大家都帮帮忙啊,急~~~~~~~~~~~~~~~~~~~~Top
3 楼decal(我用DELPHI)回复于 2006-04-12 15:20:17 得分 30
好东西,有资料分享啊楼主,支持Top




