您的位置:首页 > 其它

获取Excel的sheet名称和数量

2009-05-12 16:18 309 查看
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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: