[英]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.