标题:关于读取excel表格数据的疑问?
只看楼主
xhibm
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2009-9-16
结帖率:40%
已结贴  问题点数:10 回复次数:1 
关于读取excel表格数据的疑问?
想读取I:\test.xlsx中的第一个单元格的字符串数据,用下面的代码运行时出错,提示问题出在第4行,请高手帮忙修改,或者给出更简单的方法。         
Excel.Application excelApp = new Excel.ApplicationClass();
Excel.Workbook workbook = excelApp.Workbooks.Open(@"I:\test.xlsx");
Excel.Worksheet worksheet = workbook.Sheets[1] as Excel.Worksheet;
Excel.Range range = worksheet.Range[worksheet.Cells[1, 1],Type.Missing];
MessageBox.Show(range.Value2.ToString());



           
                       
                                 
搜索更多相关主题的帖子: excel表格 疑问 字符串 
2012-08-11 16:50
jockey
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:977
专家分:52
注 册:2005-12-4
得分:10 
Excel.Application excelApp1 = new Excel.ApplicationClass();
                Excel.Workbook workbook = excelApp1.Workbooks.Open(@"d:\总表3月.xls", missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
                Excel.Worksheet worksheet =workbook.ActiveSheet as Excel.Worksheet;

                Excel.Range range = (Range) worksheet.Cells[1, 1];  //第4行

                MessageBox.Show(range.Value2.ToString());


2012-08-13 12:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-375100-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.044381 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved