D
dgtg0710
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TSisjForm.ToolButton6Click(Sender: TObject);
var
Temp_WorkSheet : _WorkSheet;
Temp_QueryTable: _QueryTable;
Excel_Sql,Excel_Conn:OleVariant;
Excel_Range : ExcelRange;
Excel_Con ; String ;
begin
ExcelApplication1.Connect ;
Excel_Con := 'ODBC;DRIVER=SQL Server;SERVER=(local);UID=sa;PWD=;APP=楍牣獯景彴儠敵祲;WSID=P7H7T6;DATABASE=rlgl';
ExcelApplication1.Visible[0] := True ;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(EmptyParam,0) );
Temp_Worksheet := ExcelWorkbook1.Worksheets.Add(EmptyParam,EmptyParam,EmptyParam,EmptyParam,0) as _Worksheet;
ExcelWorkSheet1.ConnectTo(Temp_Worksheet);
Excel_Conn := DMForm.Excel_Con ;
Excel_Sql := 'select id 编号,xm 姓名 from OIL_SIJI';
Excel_Range := ExcelWorksheet1.Cells ;
Temp_QueryTable := ExcelWorkSheet1.QueryTables.Add(Excel_Conn,Excel_Range,Excel_Sql) ;
ExcelQueryTable1.ConnectTo(Temp_QueryTable);
ExcelQueryTable1.Refresh ;
ExcelWorksheet1.PageSetup.CenterHeader := '司机清单';
ExcelWorksheet1.PageSetup.RightFooter := '第&P页' ;
ExcelWorksheet1.PageSetup.PrintGridlines := True ;
ExcelWorksheet1.PrintOut ;
ExcelApplication1.ActiveWorkbook.Saved[0] := true ;
end;