怎样读取一个Excel文件,然后将每一个工作表的名称改为当前工作表中的某一个单元格的内容?谢谢!

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/3446/3446525.xml?temp=.5625269
      

  2.   

    在Uses中包含ComObjvar
      olehandle, workbook: OleVariant;
      i: integer;
      tstr: string;
    begin
      try
        olehandle := GetActiveOleObject('excel.application');
      except
        try
          olehandle := CreateOleObject('excel.application');
        except
        end;
      end;  WorkBook := olehandle.WorkBooks.Open('d:\book1.xls');
      for i := 1 to workbook.worksheets.count do
      begin
        tstr := WorkBook.WorkSheets[i].Cells[1, 1];
        tstr := Trim(tstr);
        if tstr <> '' then
          WorkBook.WorkSheets[i].Name := tstr;
      end;
    end;