如何在VB.net中编辑单元格值-使用.Interop.Excel [英] How to edit cell value in VB.net - Using .Interop.Excel
本文介绍了如何在VB.net中编辑单元格值-使用.Interop.Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个简单的问题。我有以下代码:
This is a simple question. I have this code:
CurrentRow = 3
MyColumn = 2
CurrentCell = (CurrentRow & "," & MyColumn)
WorkingSheet.Cells(CurrentCell).value = (ClientName & " " & "(" & ClientLocation & ")" & " " & ExtraDefinition)
我认为这会将数据放置在 WorkingSheet上的 B3位置,但会将数据放置在
I thought that this would place the data on the 'WorkingSheet' in the position "B3" but it places the data in the cell "AF1".
为什么?
谢谢,
乔什
推荐答案
单元格
是不期望的在使用时被使用;您必须输入以逗号分隔的行和列索引(作为整数)。因此正确的代码是:
Cell
is not expected to be used as you are using it; you have to input the row and column indices (as integers) separated by a comma. Thus the right code is:
WorkingSheet.Cells(CurrentRow, MyColumn).Value = (ClientName & " " & "(" & ClientLocation & ")" & " " & ExtraDefinition)
另一个选择使用的是 Range
。示例:
Another alternative you have is using Range
. Example:
WorkingSheet.Range("B3").Value = (ClientName & " " & "(" & ClientLocation & ")" & " " & ExtraDefinition)
这篇关于如何在VB.net中编辑单元格值-使用.Interop.Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文