N
nanqiu
Unregistered / Unconfirmed
GUEST, unregistred user!
由于属性很多,我在处理报表打印时候把数据通过控件button导入excel中进行.但是在编译的时候出现一条错误:[Fatal Error] Unit7.pas(94): File not found: 'XLConst.dcu'
该控件button的代码是rocedure Tfrmjlk.Button1Click(Sender: TObject);
begin
XLApp:= CreateOleObject('Excel.Application');
XLApp.visible:=true;
XLApp.workbooks.add(xlwbatworksheet);
XLApp.workbooks[1].name:='delphi data';
insertdata;
handlerange;
changecolumns;
end;
procedure Tjlkfrm.insertdata;
var
i:integer;
sheet:variant;
begin sheet:=XLApp.workbooks[1].worksheets['delphi data];
for i:=1 to 32 do sheet.cell[i,1]:=1;
sheet.cell[i,1]:='sum(A1:A32)';
end;
end;
procedure Tjlkfrm.handlerange;
var range:variant;
begin
range:=XLApp.workbooks[1].works[1].worksheets['delphi data'].range[C1:f25];
range.formula:='=RAND()';
range.columns.interior.colorindex:=3;
range.border.linestyle:=xlcontinous;
end;
procedure Tjlkfrm.changecolumns;
var
columnsrange:variant;
begin
columnsrange:=XLApp.workbooks[1].worksheets['delphi data'].columns;
columnsrange.columns[1].columnwidth:=5;
columnsrange.columns.items[1].font.bold:=true;
columnsrange.columns[1].font.color:=clblue;
end;
请各位大侠帮忙了.
该控件button的代码是rocedure Tfrmjlk.Button1Click(Sender: TObject);
begin
XLApp:= CreateOleObject('Excel.Application');
XLApp.visible:=true;
XLApp.workbooks.add(xlwbatworksheet);
XLApp.workbooks[1].name:='delphi data';
insertdata;
handlerange;
changecolumns;
end;
procedure Tjlkfrm.insertdata;
var
i:integer;
sheet:variant;
begin sheet:=XLApp.workbooks[1].worksheets['delphi data];
for i:=1 to 32 do sheet.cell[i,1]:=1;
sheet.cell[i,1]:='sum(A1:A32)';
end;
end;
procedure Tjlkfrm.handlerange;
var range:variant;
begin
range:=XLApp.workbooks[1].works[1].worksheets['delphi data'].range[C1:f25];
range.formula:='=RAND()';
range.columns.interior.colorindex:=3;
range.border.linestyle:=xlcontinous;
end;
procedure Tjlkfrm.changecolumns;
var
columnsrange:variant;
begin
columnsrange:=XLApp.workbooks[1].worksheets['delphi data'].columns;
columnsrange.columns[1].columnwidth:=5;
columnsrange.columns.items[1].font.bold:=true;
columnsrange.columns[1].font.color:=clblue;
end;
请各位大侠帮忙了.