Excel.Application read cell value get" Type mismatch"错误 [英] Excel.Application read cell value get "Type mismatch" error

查看:116
本文介绍了Excel.Application read cell value get" Type mismatch"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码非常简单,打开c:\ test.csv文件,然后将存储在单元格1,1下的值写入屏幕。

The following code is very straightforward, open c:\test.csv file and then write the value stored under cell 1,1 to the screen.

WScript.Echo objWorkSheet.Cells(1,1).Value

WScript.Echo objWorkSheet.Cells(1,1).Value

大多数情况下都能正常工作。但是我发现(1,1)中的值是否以"+"开头。或" - ",将发生类型不匹配错误。有什么建议来处理这个问题吗?

This works fine in the most cases. However I found if the value in (1,1) is starting with "+" or "-", a type mismatch error will occur. Any suggestion to handle this issue?

test.csv类似于以下

The test.csv is like the following

" -teststring"," hello"," -2-3"

"-teststring","hello","-2-3"

似乎程序不只是读取值而且还试图进行计算。在上面的示例中,如果更改"-teststring", to"teststring"你会看到从"1,3"读取的值。变为-5而不是"-2-3"。
我只想把所有内容都读成文字。

It seems the program is not just reading the value but also trying to make the calculation. In the example above, if change "-teststring" to "teststring" you will see the value read from "1,3" become -5 instead of "-2-3". I just want to read everything as text.

谢谢!

推荐答案

您好,

这似乎不是VB.NET代码,您可以指定项目类型,例如VB6(我们不支持),VBA(我可以将您的问题转移到正确的论坛)?

This does not appear to be VB.NET code, can you specify the project type e.g. VB6 (we don't support), VBA (I can move your question to the correct forum) ?


这篇关于Excel.Application read cell value get" Type mismatch"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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