install pack dcloffice2k50.bpl //update pack 1 have
替换原来的dclaxserver50.bpl
连接access数据库用ado.
添加excelapplication,excelworkbook,excelworksheet.
source://类是这样
ExcelApplication.Connect;
// ExcelApplication1.Visible[0]:=true;
ExcelApplication.Workbooks.Add(ExtractFilePath(application.exename)+'档案模版.xlt',0);
ExcelWorkbook1.ConnectTo(ExcelApplication.Workbooks[1]);
// ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Sheets[1] as _WorkSheet);
//write the field name
{ for idx:=0 to DB.Fields.Count-1 do
ExcelWorksheet1.Cells.Item[1,idx+1]:=DB.Fields[idx].FieldName;}
recordno:=3;
PageNo:=0;
While Not Table.Eof do
begin
if recordno=3 then//the new page is start...
begin
pageno:=pageno+1;
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Sheets[excelapplication.sheets.count] as _WorkSheet);
excelworksheet1.Copy(excelworkbook1.sheets[excelapplication.sheets.count] as _worksheet);
excelworksheet1.ConnectTo(excelworkbook1.sheets[excelapplication.sheets.count-1] as _worksheet);
excelworksheet1.name:='第'+IntToStr(PageNo)+'页';
end;
for idx:=0 to Table.Fields.Count-1 do
ExcelWorksheet1.Cells.Item[recordno,idx+1]:=Table.Fields[idx].AsString;
if recordno<12 then
recordno:=recordno+1
else
recordno:=3;
Table.Next;
end;
// excelworksheet1.ConnectTo(excelworkbook1.sheets[excelapplication1.sheets.count] as _worksheet);
// excelworksheet1.Delete;
//free the excel application
ExcelWorkBook1.SaveCopyAs(SaveDialog1.FileName);
ExcelWorkBook1.Close(false);
ExcelApplication.Disconnect;
ExcelApplication.Quit;