M
mxcen
Unregistered / Unconfirmed
GUEST, unregistred user!
我用了server中的ExcelApplication,ExcelWorkbook,ExcelWorksheet控件做,但是往往第一次运行就很顺利,运行第二次开始EXCEL就输不出了,一直EXCEL都死机在那里动到不动一下,怎么办呢?急,那位能帮帮我,感激不尽,代码如下:<br><br>var<br>i,row,column:integer;<br>begin<br>Try<br>ExcelApplication1.Connect;<br>Except<br>MessageDlg('Excel may not be installed',<br>mtError, [mbOk], 0);<br>Abort;<br>End;<br>ExcelApplication1.Visible[0]:=True;<br>ExcelApplication1.Caption:='Excel Application';<br>ExcelApplication1.Workbooks.Add(Null,0);<br>ExcelWorkbook1.ConnectTo<br>(ExcelApplication1.Workbooks[1]);<br>ExcelWorksheet1.ConnectTo<br>(ExcelWorkbook1.Worksheets[1] as _Worksheet);<br>DM.ATrkjlb.Open;<br>dm.ATrkjlb.First ;<br>ExcelWorksheet1.Cells.Item[1,1]:='ID';<br>ExcelWorksheet1.Cells.Item[1,2]:='生产单号';<br>ExcelWorksheet1.Cells.Item[1,3]:='客户名称';<br>ExcelWorksheet1.Cells.Item[1,4]:='订单号';<br>ExcelWorksheet1.Cells.Item[1,5]:='产品编号';<br>ExcelWorksheet1.Cells.Item[1,6]:='品名';<br>ExcelWorksheet1.Cells.Item[1,7]:='规格';<br>ExcelWorksheet1.Cells.Item[1,8]:='入库数量';<br>ExcelWorksheet1.Cells.Item[1,9]:='入库时间';<br>ExcelWorksheet1.Cells.Item[1,10]:='放置区域';<br>ExcelWorksheet1.Cells.Item[1,11]:='备注';<br>row:=2;<br>While Not(DM.ATrkjlb.Eof) do<br>begin<br>column:=1;<br>for i:=1 to DM.ATrkjlb.FieldCount do<br>begin<br>ExcelWorksheet1.Cells.Item[row,column]:=DM.ATrkjlb.fields[i-1].AsString;<br><br>column:=column+1;<br>end;<br>DM.ATrkjlb.Next;<br>row:=row+1;<br>end;<br>end;