我猜来的代码:
procedure TForm1.Button1Click(Sender: TObject);
var dirname,filename,mystr1:string;
ir:integer;
//range:variant;
//olecon: TOleContainer;
begin
// chdir('//138.1.6.2/dyeing/lab/²âÊÔ·¿²âÊÔ±¨¸æ/2006 ²âÊÔ½á¹û±¨¸æ/²âÊÔ×ܽá/²»Í¬²¼ÖÖ²âÊÔͳ¼Æ');
chdir('D:/');
if ioresult <> 0 then
showmessage('Ö¸¶¨Ä¿Â¼ÎÞ·¨Çл»')
else
begin
showmessage('Ŀ¼³É¹¦Çл»');
//od1.InitialDir:='//138.1.6.2/dyeing/lab/²âÊÔ·¿²âÊÔ±¨¸æ/2006 ²âÊÔ½á¹û±¨¸æ/²âÊÔ×ܽá/²»Í¬²¼ÖÖ²âÊÔͳ¼Æ';
od1.InitialDir:='D:/';
if od1.Execute then
begin
filename:=od1.FileName;
ExcelApplication1.Workbooks.Open(FileName,null,null,null,null,null,null,null,null,null,null,null,null,0);
excelapplication1.Visible[0]:=true;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelApplication1.Worksheets[0] as _worksheet);
end;
// ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[day] as _Worksheet);
// ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1]) as _Worksheet );
// ExcelWorksheet1.ConnectTo(ExcelWorkbook1.WorkSheets.Add(EmptyParam,EmptyParam,EmptyParam,EmptyParam,0) as _WorkSheet);
// ir:=ExcelWorksheet1.[a65535].End(xlUp).Row + 1 ;
ir := ExcelApplication1.Sheets('sheet1').[a65535].End(xlUp).Row + 1;
// Range(Cells(iR, 1), Cells(iR, 1)).Value := 'datetime' ;
ExcelWorksheet1.Cells(15, 1).Value := 'datetime' ;
end;
end;