L
liuguilg
Unregistered / Unconfirmed
GUEST, unregistred user!
我下载加载了Ehlib,然后照着这个列子,怎么也运行不通过 错误为
[Error] Unit1.pas(34): Undeclared identifier: 'TDBGridEhExportClass'
[Error] Unit1.pas(42): Undeclared identifier: 'TDBGridEhExportAsText'
[Error] Unit1.pas(43): Undeclared identifier: 'TDBGridEhExportAsCSV'
[Error] Unit1.pas(44): Undeclared identifier: 'TDBGridEhExportAsHTML'
[Error] Unit1.pas(45): Undeclared identifier: 'TDBGridEhExportAsRTF'
[Error] Unit1.pas(46): Undeclared identifier: 'TDBGridEhExportAsXLS'
[Error] Unit1.pas(50): Operator not applicable to this operand type
[Error] Unit1.pas(54): Undeclared identifier: 'SaveDBGridEhToExportFile'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
或者是需要哪些控件
例:将当前表格中数据导出为EXCEL等格式文件。
在窗体中添加一个SaveDialog组件和“导出”按钮B_exp,在“导出”按钮的click事件中添加如下代码:
procedure TForm1.B_expClick(Sender: TObject);
var
ExpClass:TDBGridEhExportClass;
Ext:String;
begin
SaveDialog1.FileName := 'file1';
if (ActiveControl is TDBGridEh) then
if SaveDialog1.Execute then
begin
case SaveDialog1.FilterIndex of
1: begin ExpClass := TDBGridEhExportAsText; Ext := 'txt'; end;
2: begin ExpClass := TDBGridEhExportAsCSV; Ext := 'csv'; end;
3: begin ExpClass := TDBGridEhExportAsHTML; Ext := 'htm'; end;
4: begin ExpClass := TDBGridEhExportAsRTF; Ext := 'rtf'; end;
5: begin ExpClass := TDBGridEhExportAsXLS; Ext := 'xls'; end;
else
ExpClass := nil; Ext := '';
end;
if ExpClass <> nil then
begin
if UpperCase(Copy(SaveDialog1.FileName,Length(SaveDialog1.FileName)-2,3)) <> UpperCase(Ext) then
SaveDialog1.FileName := SaveDialog1.FileName + '.' + Ext;
SaveDBGridEhToExportFile(ExpClass,DBGridEh1,SaveDialog1.FileName,False);
//其中false为局部数据
end;
end;
end;
[Error] Unit1.pas(34): Undeclared identifier: 'TDBGridEhExportClass'
[Error] Unit1.pas(42): Undeclared identifier: 'TDBGridEhExportAsText'
[Error] Unit1.pas(43): Undeclared identifier: 'TDBGridEhExportAsCSV'
[Error] Unit1.pas(44): Undeclared identifier: 'TDBGridEhExportAsHTML'
[Error] Unit1.pas(45): Undeclared identifier: 'TDBGridEhExportAsRTF'
[Error] Unit1.pas(46): Undeclared identifier: 'TDBGridEhExportAsXLS'
[Error] Unit1.pas(50): Operator not applicable to this operand type
[Error] Unit1.pas(54): Undeclared identifier: 'SaveDBGridEhToExportFile'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
或者是需要哪些控件
例:将当前表格中数据导出为EXCEL等格式文件。
在窗体中添加一个SaveDialog组件和“导出”按钮B_exp,在“导出”按钮的click事件中添加如下代码:
procedure TForm1.B_expClick(Sender: TObject);
var
ExpClass:TDBGridEhExportClass;
Ext:String;
begin
SaveDialog1.FileName := 'file1';
if (ActiveControl is TDBGridEh) then
if SaveDialog1.Execute then
begin
case SaveDialog1.FilterIndex of
1: begin ExpClass := TDBGridEhExportAsText; Ext := 'txt'; end;
2: begin ExpClass := TDBGridEhExportAsCSV; Ext := 'csv'; end;
3: begin ExpClass := TDBGridEhExportAsHTML; Ext := 'htm'; end;
4: begin ExpClass := TDBGridEhExportAsRTF; Ext := 'rtf'; end;
5: begin ExpClass := TDBGridEhExportAsXLS; Ext := 'xls'; end;
else
ExpClass := nil; Ext := '';
end;
if ExpClass <> nil then
begin
if UpperCase(Copy(SaveDialog1.FileName,Length(SaveDialog1.FileName)-2,3)) <> UpperCase(Ext) then
SaveDialog1.FileName := SaveDialog1.FileName + '.' + Ext;
SaveDBGridEhToExportFile(ExpClass,DBGridEh1,SaveDialog1.FileName,False);
//其中false为局部数据
end;
end;
end;