excel一般都只有3个sheet,怎样动态的添加sheet,比如安徽省有17个市,怎样添加17个sheet?在线等!!!!!!解决可以加分!

解决方案 »

  1.   

    你可以通过你的本机的Excel应用设定,确定你缺省的Excel Sheet数量,范围是1..9。
      

  2.   

    ExcelID := CreateOleObject( 'Excel.Application' );
    ExcelID.WorkBooks.Add;
    ExcelID.WorkSheets[2].Activate;//设置哪一个Sheet为当前Sheet
    ExcelID.WorkSheets.Add;//在当前Sheet前插入新的Sheet
      

  3.   

    var
      ExcelApp: Variant;
    begin
      ExcelApp := CreateOleObject( 'Excel.Application' );
      ExcelApp.Visible := True;
      ExcelApp.WorkBooks.Add; //添加新工作簿
      ExcelApp.Sheets.Add; 第4个Sheets
      ExcelApp.Sheets.Add; 第5个Sheets
      ExcelApp.Sheets.Add; 第6个Sheets
      .........
      //需要多少个就添加总数减3个 ExcelApp.Sheets.Add;
    end;