在access表我对需要的数据部分选定,然后复制,在excel中在选定的区域
粘贴。可以。
其它的数据表,你照此试一试。
粘贴。可以。
其它的数据表,你照此试一试。
解决方案 »
- delphi SQL Server不存在或拒绝访问
- 如何在delphi中实现SQL的数据备份和还原
- 文件拷贝问题。调用API函数,进行拷贝。正在拷贝时,点击取消,如何取得返回值???
- (超紧急)能不能在已经查询出来的recordset中添加一个字段并给予赋值?
- 新手的qreport问题,如何在报表中显示总的页码数,望各位大虾帮助解决。
- 一个非常急的问题,大家快帮忙啊!!!!!!!
- 在dll里加上一个form1, 我如何申明它,让程序调用?
- delphi+ado+Sql 重复记录异常处理问题
- 请问TryStrTo***的帮助文档哪里有的找?
- 一个巨难的问题!至今尚无人能解!!
- 有关内存泄漏
- 请问这个问题
要自己写,一句话好像说不完,涉及COM。
可以到已解决区找一找,应该有的。
...
Var
Sheet,ExcelApp:Variant;
begin
ExcelApp:=CreateOleObject('Excel.Application');
ExcelApp.Visible:=True;
ExcelApp.workbooks.add(GetCurrentDir() + '\' + 'Demo.xls'); //一般都是在一个模板文件里写数据
Sheet:=ExcelApp.workbooks[1].worksheets[1];
Sheet.cells[25,4].Value := 'Hello,Excel!';
end;
var
Excel,WorkBook, Sheet:variant;
Col, Row,iRow : Integer;
s:string;
begin
If Application.MessageBox('导入Excel?','系统提示',MB_OKCANCEL + 32)<>IDOk then Exit;
try
Excel:= Unassigned;
Excel:=GetActiveOleObject('Excel.Application');
except
Try
Excel:=UnAssigned;
Excel:=CreateOleObject('Excel.Application');
Except
Application.MessageBox(请确认是否正确安装Excel!','系统提示',MB_OK + 48);
end;
end;
Excel.Visible:=True;
Excel.DisplayAlerts:=false;
Excel.WorkBooks.Add;
Excel.SheetsInNewWorkbook := 1;
WorkBook := Excel.WorkBooks.Add;
Sheet := WorkBook.WorkSheets[1];
Sheet.Name:=Caption;
Row := 2;
Sheet.Rows[Row].Font.Bold := True;
inc(Row,2);
Sheet.Rows[Row].Font.Bold := True;
with DataSource1.Dataset do begin
for Col := 0 to FieldCount-1 do
if Fields[col].visible = True then
Sheet.Cells[Row, Col+1] := Fields[col].DisplayName;
inc(Row);
First;
while not Eof do begin
for Col := 0 to FieldCount-1 do begin
if Fields[col].visible = false then continue;
s:=' '+Fields[col].AsString;
Sheet.Cells[Row, Col+1]:=s;
end;
Inc(Row);
next;
end;
end;
Sheet.Cells.Columns.AutoFit;
Sheet.Cells[2, 2] := Main_Screen.Company_Name + ' '+Caption;
end;
MSExcel:Variant;
i,j:integer;
begin
SaveDialog1.Filter:='*.XLS|*.XLS';
SaveDialog1.DefaultExt:='XLS';
if SaveDialog1.Execute then
begin
MsExcel:=createOLEobject('excel.application');
MsExcel.workBooks.add;
Msexcel.visible:=false;
with dm.adchaxun do
begin
first;
for i:=0 to fieldcount-1 do
begin
Msexcel.cells[1,i+1].value:=fields[i].DisplayLabel ;
end;
j:=2;
while not eof do
begin
for i:=0 to fieldcount-1 do
begin
Msexcel.cells[j,i+1].numberformat:='@';
Msexcel.cells[j,i+1].value:=fields[i].AsString ;
end;
inc(j);
next;
end;
end;
MSExcel.ActiveWorkBook.SaveAs(SaveDialog1.FileName);
MSExcel.ActiveWorkBook.Saved:=True;
MSExcel.Quit;
end;
end;