我用Table控件查询出来数据想把这些数据导到Excel.!
解决方案 »
- 【热】秩为0的 SafeArray 被传递到需要秩为1的数组的方法中【请教】
- DELPHI,创建风格化的菜单窗体和调用问题...在线等待!
- varisempty(clientdataset.delta)在delta is empty是出错 怎么处理??在线等待............
- 大富翁是不是被别人给黑了,怎么这个样子了??大家快看看啊!
- 如何对多个edit控件整体赋值?
- 菜鸟提问大虾
- 如何得到access数据库中的所有表名。
- 如何建立同ADO相同的所有者
- 哪位用过BoundsChecker for Delphi啊?它怎么与Delphi集成调试?
- 小生想学习DELPHI,但不知那一本书比较好,请各位多多指教。
- 如何把stringgrid中的数据添加进数据库
- 关于TreeView的问题
procedure TForm1.aa;
var
i,j:integer;
excel_sheet:variant;
begin
try
excel_sheet:=CreateOleObject('Excel.Application');
except
showmessage('无法启动 MS Excel');
exit;
end;
With table1 do
begin
first;
Excel_sheet.WorkBooks.Add;
for i:=0 to RecordCount-1 do
begin
for j:=0 to FieldCount-1 do excel_sheet.cells.item[i+1,j+1]:=Fields[j].AsString;
next;
end;
excel_sheet.ActiveWorkBook.saveas(文件路径);
excel_sheet.application.quit;
end;
end;
procedure Tearningstool.Button1Click(Sender: TObject);
var xlapp,xlbook,xlsheet:variant;
i,j:integer;
begin
self.Cursor:=crHourGlass;
xlapp:=createoleobject('excel.application');
xlbook:=xlapp.workbooks.add;
xlsheet:=xlbook.worksheets[1];
xlsheet.cells[1,3]:='标题';
xlsheet.cells[2,1]:='name1';
xlsheet.cells[2,2]:='name2';
...
i:=3;
for j:=1 to self.StringGrid2.rowcount-1 do
begin
xlsheet.cells[i,1]:=''''+trim(self.StringGrid2.Cells[0,j]);
xlsheet.cells[i,2]:=trim(self.StringGrid2.Cells[1,j]);
xlsheet.cells[i,3]:=trim(self.StringGrid2.Cells[2,j]);
xlsheet.cells[i,4]:='';
xlsheet.cells[i,5]:=''''+trim(self.StringGrid2.Cells[4,j]);
xlsheet.cells[i,6]:=trim(self.StringGrid2.Cells[5,j]);
xlsheet.cells[i,7]:=trim(self.StringGrid2.Cells[6,j]);
i:=i+1;
end;
self.Cursor:=crDefault;
xlapp.visible:=true;
end;
如果不是Table,而是查询的adoquery或者adostoredproc,会不会有限制?
我这边只能出现255条记录