VB.net Excel.worksheet().cells().Value [英] VB.net Excel.worksheet().cells().Value

查看:88
本文介绍了VB.net Excel.worksheet().cells().Value的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图在Excel工作表中编写信息但是有一些奇怪的问题;)我在Google上查看了信息,但没有结果.所以请帮忙)

Trying to write information in Excel worksheet But have some strange problems ;) i looked info on Google but no result.. So plz help )

我添加了参考Microsoft.excel 14.0对象库并导入Microsoft.Office.interop

I Add reference Microsoft.excel 14.0 Object Library and also Import Microsoft.Office.interop

我需要从特定单元格获取价值所以我使用命令Checker = shXL.cells(1,1).在这里,我没有价值.我只有这个(等于/GetHashCode/GetType/toString)所以问题是为什么我没有.cell的(.Value)以及错误在哪里

I need to get Value from specific cell so i use command Checker = shXL.cells(1,1). And here i don't have Value.... i only got this (Equal / GetHashCode / GetType / toString) So question is WHY i don't have (.Value) for .cells and where is an Error

        Dim appXL As Excel.Application
        Dim wbXL As Excel.Workbook
        Dim wbsXL As Excel.Workbooks
        Dim shXL As Excel.Worksheet
        Dim Checker As Integer

        appXL = CreateObject("excel.application")
        appXL.Visible = True

        wbsXL = appXL.Workbooks
        wbXL = wbsXL.Open("D:\Некорректные Переключения\Base.xlsx", , , , 12121)
        shXL = wbXL.ActiveSheet
        Checker = shXL.Cells(1, 1).value()

最诚挚的问候和THX!

Best Regards and THX!

推荐答案

这是因为 .Cells()返回一个对象.

That's because .Cells() returns an object.

您可以尝试在另一步骤中将其转换为Excel Cell 对象,也可以尝试以下操作(例如):

You can try converting it to a Excel Cell object in another step, or you can try this (for example):

shXL.Range("A2").Value

随着转化将是:

Dim xRng As Excel.Range = CType(shXL.Cells(3,3), Excel.Range)
Dim val As Object = xRng.Value()

这篇关于VB.net Excel.worksheet().cells().Value的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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