我的集合中有三列 ( First Name , Last Name and phone Number
),我使用Excel VBO 的“复制为集合”功能从 excel 中获得。
请注意,末尾有多余的空格First name and Phone number
。我想修剪这些空间。请建议如何做到这一点。另请注意,我没有在我的集合中定义列名。我直接从 excel 中复制它,这样如果在 excel 中进行任何更改,它就会动态地反映在集合中。
谢谢...
集合操作对象中有多个动作。您需要使用读取字段操作并使用某些逻辑重命名字段操作。
您可以使用操作:
Object: Utility - Collection Manipulation
Action: Trim Collection
如果您的对象中没有它,那么您可以将它添加到您的对象中。请看下面的代码:
Dim i as integer
Dim j as integer
'For Each Column As DataColumn In Input_Collection.Columns
For j = 0 to Input_Collection.Columns.Count -1
For i = 0 to Input_Collection.Rows.Count -1
'dim x as string =CStr(Input_Collection.Rows(i)(j)).Trim()
Input_Collection.Rows(i)(j)= CStr(Input_Collection.Rows(i)(j)).Trim()
Next
Next
Output_Collection = Input_Collection
或者你可以使用
对象:实用程序 - 集合操作
行动:从标题中删除点 并在代码中更改“。” 至 ” ”
请在下面找到确切的代码并将其粘贴到代码阶段:
For Each Column As DataColumn In Input_Collection.Columns
Column.ColumnName=Microsoft.Visualbasic.Replace(Column.ColumnName," ","")
Next
Output_Collection = Input_Collection