J
jiangxidna
Unregistered / Unconfirmed
GUEST, unregistred user!
我现在用delphi2007编程,数据库用的是sql server。现在我想实现打印功能 。用了以前用的一种方法(delphi7+oracle)来实现,出现错误。这是代码:<br>procedure TfrmTowerPullStatistics.sBtnPrintClick(Sender: TObject);<br>var<br> Sheet,ExcelApp : variant;<br> i,j : integer;<br>begin<br> inherited;<br>ExcelApp:=CreateOleObject('Excel.Application');<br> ExcelApp.Visible:=TRUE;<br> ExcelApp.WorkBooks.Add[GAppPath+'/Xls/塔杆受力监测数据.xlt'];<br> Sheet:=ExcelApp.WorkBooks[1].WorkSheets['Sheet1'];<br> ExcelApp.DisplayAlerts:=FALSE;<br> IF EPDM.PowerDM.Query3.State =dsBrowse Then<br> Begin<br> EPDM.PowerDM.Query3.First;<br> with EPDM.PowerDM.Query3 do<br> while not eof Do<br> Begin<br> For i:=0 to RecordCount-1 do<br> Begin<br> Sheet.Cells[i+3,1] :=FieldByName('xlmc').asstring;<br> Sheet.Cells[i+3,2] :=FieldByName('btgh').asstring;<br> Sheet.Cells[i+3,3] :=FieldByName('byqckdlax').asstring;<br> Sheet.Cells[i+3,4] :=FieldByName('byqckdlbx').asstring;<br> Sheet.Cells[i+3,5] :=FieldByName('byqckdlcx').asstring;<br> Sheet.Cells[i+3,6] :=FieldByName('sxbphl').asstring;<br> next;<br> end;<br> end;<br> end<br> else<br> Begin<br> MessageBoxes('没有数据可以打印');<br> exit;<br> end;<br>end;<br><br>end.