var
lcid,maxnumber,i:integer;
Template:string;
yearmonth,tmpsqlstr:string; // yearmonth存放年月,tmpsqlstr存放临时sql语句,msgstr存放显示的消息
flaga:boolean;
qry_tmp:Tadoquery;
begin
lcid := GetUserDefaultLCID;
try
ExcelApplication1.Connect;
ExcelApplication1.Visible[lcid]:=false;
if OpenDialog1.Execute then
begin
Template:=OpenDialog1.FileName;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Open(template,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,Lcid));
...
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets as _Worksheet);
val:= ExcelWorksheet1.Range['b7','b7'].Value; //val的赋值为b7单元内容