不知道能不能提供一点帮助,乱写,希望修正!谢谢
ExcelApp.Worksheets.Add这个不会用,请指点
var ExcelApp : TExcelApplication;
Excelbook : TExcelWorkbook;
Excelsheet : TExcelWorksheet;
Temp_Worksheet: _WorkSheet;
Datas :variant;
i : integer;
begin
i:=1;
ExcelApp := TExcelApplication.Create(nil);
Excelbook := TExcelWorkbook.Create(nil);
Excelsheet := TExcelWorksheet.Create(nil);
try
ExcelApp.Connect;
except
Messagedlg('Not Install Excel ',mtInformation,[mbOK],0);
abort;
end;
try
Excelbook.ConnectTo(
ExcelApp.Workbooks.Open( Edit1.Text,EmptyParam,
EmptyParam,EmptyParam,
EmptyParam,EmptyParam,
EmptyParam, EmptyParam,
EmptyParam, EmptyParam,
EmptyParam, EmptyParam,
EmptyParam, 0) );
except
end;
Temp_Worksheet := Excelbook.Worksheets as _WorkSheet ;
Excelsheet.ConnectTo(Temp_Worksheet);
Excelsheet.Select;
Datas:= varArrayCreate([1,1000,1,40],varVariant);
Datas:= Excelsheet.Range[Excelsheet.Cells.Item[1,1],Excelsheet.Cells.Item[1000,40]].Value;
ExcelApp.Worksheets.Add(EmptyParam,EmptyParam,EmptyParam,EmptyParam,0);
Temp_Worksheet := Excelbook.Worksheets as _WorkSheet ;
Excelsheet.ConnectTo(Temp_Worksheet);
Excelsheet.Select;
Excelsheet.Range[Excelsheet.Cells.Item[1,1],Excelsheet.Cells.Item[1000,40]].Value :=Datas;
ExcelApp.Disconnect;
ExcelApp.Free;