获取Excel的sheet名称和数量

string name=sheet.Name; //获取该sheet的名称
   string amount=book.WorkSheets.Count.ToString(); //获取该book的sheet数量。
     string sSheetName=null;
     object missing = Missing.Value;
      OleDbConnection conn = new OleDbConnection();
      Excel.Application excelApp = new Excel.Application();
     excelApp.Application.Workbooks.Open(path, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,Missing.Value ,Missing.Value,Missing.Value,Missing.Value ,Missing.Value ,Missing.Value );
       for (int i = 0; i < excelApp.Workbooks[1].Worksheets.Count; i++)
        {
          Excel.Worksheet ws = (Excel.Worksheet)excelApp.Workbooks[1].Worksheets[1];
          sSheetName = ws.Name;
        }
posted @ 2009-05-12 16:18  居后不争  阅读(3072)  评论(0编辑  收藏  举报