如何阅读Excel工作表的第一行? [英] How to read the first row of an Excel sheet?

查看:96
本文介绍了如何阅读Excel工作表的第一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码读取Excel工作表.我只想读取单列表中的第一行.我的单元格是"B1".如何使用此代码进行操作?


I''m using this code to read an Excel sheet. I want to read only the first row in a single column table. My cell is "B1". How do i do that using this code?


using Excel = Microsoft.Office.Interop.Excel;

string ExcelFile = Application.StartupPath + @"\SurveyLinks.xlsx";
Excel.Application ExcelApp = new Excel.Application();
Excel.Workbook ExcelWorkBook = ExcelApp.Workbooks.Open(ExcelFile);
Excel._Worksheet ExcelWorkSheet = ExcelWorkBook.Sheets[1];
Excel.Range ExcelRange = ExcelWorkSheet.

我不知道在"ExcelWorksheet"之后要插入什么.有任何想法吗?

I dont know what to insert after "ExcelWorksheet." Got any ideas?

推荐答案

请参考以下两个链接,您可能会找到解决方法:

http://stackoverflow. com/questions/3022053/how-can-i-read-only-first-row-from-excel-file-with-oledbdataadapter [ http://www.dreamincode.net/forums /topic/56664-how-to-access-excel-sheet-using-c%23/ [
Refer these two links you may find solution:

http://stackoverflow.com/questions/3022053/how-can-i-read-only-first-row-from-an-excel-file-with-oledbdataadapter[^]


http://www.dreamincode.net/forums/topic/56664-how-to-access-excel-sheet-using-c%23/[^]

Observe the select statement.


这似乎是您三天前发布的几乎相同的问题.您先前问题的解决方案也可以解决此问题.请检查一下:如何删除使用Excel互操作的excel文件的第一行? [
Hi, that seem almost the same question posted by you three day ago. And the solution for your earlier question can solve this question too. Have a check please: How to delete the first row of an excel file using Excel interop?[^]


这篇关于如何阅读Excel工作表的第一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆