怎么用C#获得Excel里面Sheet的个数和每个Sheet的名称
1个回答
展开全部
string str = @"C:\Program Files\Data\SpaceKeyword.xlsx";
object missing = Missing.Value;
Application app = null;
Workbook wb = null;
Worksheet ws = null;
app = new Microsoft.Office.Interop.Excel.Application();
wb = app.Workbooks.Open(str, false, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
app.Visible = false;//读Excel不显示出来影响用户体验
ws = (Worksheet)wb.Worksheets.get_Item(1);//读取第一个sheet表,表名看ws属性就ok
object missing = Missing.Value;
Application app = null;
Workbook wb = null;
Worksheet ws = null;
app = new Microsoft.Office.Interop.Excel.Application();
wb = app.Workbooks.Open(str, false, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
app.Visible = false;//读Excel不显示出来影响用户体验
ws = (Worksheet)wb.Worksheets.get_Item(1);//读取第一个sheet表,表名看ws属性就ok
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |