简体   繁体   English

如何读取现有的 Excel 电子表格单元格(或单元格)

[英]How to read to an existing Excel spreadsheet cell (or cells)

(If my question or description is too vague please correct me) (如果我的问题或描述太模糊,请纠正我)

I want to read data from cells in an excel spreadsheet (Not everything, just a couple cells) from WinForms, use that data and display it as the Labels' text.我想从 WinForms 的 excel 电子表格(不是所有内容,只是几个单元格)中的单元格中读取数据,使用该数据并将其显示为标签的文本。 A good example of this would be, someone who has their product's inventory stored in a spreadsheet but just wants to know the number of x product that exists in his inventory.一个很好的例子是,某人将其产品的库存存储在电子表格中,但只想知道其库存中存在的 x 产品的数量。

Try This尝试这个

Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Add("Your file path here")
xlWorkSheet = xlWorkBook.Sheets("sheet1") ' Your sheet name is here
Label1.Text = xlWorkSheet.Range("B2").Value 'cell no from where you want to fetch data 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用VS 2008 VB将单元格或一系列单元格从一个Excel电子表格复制到另一个Excel电子表格 - How to copy a cell or a range of cells from one Excel spreadsheet to another Excel Spreadsheet with VS 2008 VB 如何使用 NPOI 读取包含空单元格的 Excel 电子表格? - How to use NPOI to read Excel spreadsheet that contains empty cells? 获取现有Excel电子表格中单元格的背景色 - Getting the background color of a cell in an existing Excel spreadsheet 在Excel中查找合并单元格,拆分单元格并将其写入新电子表格中? - Find merged cell in Excel, split the cells and write those in new spreadsheet? 将Excel电子表格单元格中的彩色文本解析为多个单元格? - Parsing multicolored text in Excel spreadsheet cell into multiple cells? 在A列中的空白单元格之后将两行单元格添加到Excel电子表格中 - Adding two rows of cells to an Excel spreadsheet after a blank cell in column A 读取excel单元格并确定单元格中的格式化单词 - Read excel cells and determine formatted words in cell 使用OPENXML读取时Excel电子表格行单元格乱序 - Excel spreadsheet row cells out of order when read with OPENXML 如何使用 python 将页面添加到现有的 excel 电子表格 - How to add pages to an existing excel spreadsheet with python 如何使用Java从Excel电子表格中的多个工作表中读取特定单元格的内容? - How do you read a particular cell's content from multiple sheets in an Excel spreadsheet using Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM