procedure TReport_Area_Frm.S_deleteClick(Sender: TObject);
var
filename:string;
xl,ExcelApp,WorkBook,Sheet: oleVariant;
x,y:integer;
begin
inherited;
OpenDialog1.InitialDir:=ExtractFilePath(Application.ExeName)+'报表管理';
OpenDialog1.Execute;
filename:=OpenDialog1.FileName;
if length(filename)=0 then
begin
Mymessagebox(' 没有选择历史统计文件的存储位置,不能导入历史统计文件的数 ! ',1,2);
exit;
end;
try
ExcelApp := CreateOleObject('Excel.Application');
WorkBook:=CreateOleobject('Excel.Sheet');
ExcelApp.WorkBooks.Open(filename);
ExcelApp.WorkSheets[1].Activate;
except
Mymessagebox(' 您的机器里未安装Microsoft Excel没有该文件,不能导入Excel报表! ',1,2);
exit;
end;
if ExcelApp.Cells[1,1].Value='各地区流量报表' then
begin
label1.Caption:=ExcelApp.Cells[2,1].Value;
sa_grid.RowCount:=17;
for y:=1 to sa_grid.RowCount-1 do
begin
for x:=1 to 5 do
begin
sa_grid.Cells[x,y]:=ExcelApp.Cells[y+3,x].Value;
end;
end;
end else begin
Mymessagebox(' 该Excel文件不是本系统导出的统计文件,不能导入本系统! ',1,2);
exit;
end;
WorkBook.Close;
ExcelApp.Quit;
不知道对你有用否!!!!