使用Lotus脚本,需要将多价值导出到不同行
我试图导出多价值领域,但无法实现它。我尝试了UBOUND的导出,但是情况是我需要第一行中的第一值,反之亦然。请帮助我解决这个问题。我正在使用Excel应用程序导出数据。
提前致谢。
ForAll b In fieldList
If UBound(doc.getitemvalue(b)) <1 Then
worksheet.cells(i,j).value =doc.getitemvalue(CStr(b))
Else
'Join(doc.getitemvalue(CStr(b)),Chr(10))
worksheet.cells(i,j).value =Join(doc.getitemvalue(CStr(b)),Chr(10))
End If
End Forall
I was trying to export the Multi-valued field but couldn't able to achieve it. i tried Ubound to export but the scenario is I need the 1st value in 1st row and 2nd value in 2nd row vice versa. Please help me to solve this. I'm using excel application to export the data.
Thanks in advance.
ForAll b In fieldList
If UBound(doc.getitemvalue(b)) <1 Then
worksheet.cells(i,j).value =doc.getitemvalue(CStr(b))
Else
'Join(doc.getitemvalue(CStr(b)),Chr(10))
worksheet.cells(i,j).value =Join(doc.getitemvalue(CStr(b)),Chr(10))
End If
End Forall
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建一个循环,通过索引遍历每个字段的所有值(我的代码示例中的“ x ”)。再次使用 x 再次抵消行值。
您会遇到一个问题,每个 fieldName 的值都会在电子表格中覆盖,因为 i 和 j 始终是相同的,因此您在 fieldlist 中有多个 fieldname ,您也需要对此做些事情。在我的示例中,我已经为每个 fieldname 增加了 j ,以便它们将在不同的电子表格列中
替代版本,以实现您在评论中提出的内容:
Create a loop that goes through all the values for each field by index ("x" in my code sample). Use x again to offset the row value.
You will have a problem that each fieldName's values will be overwritten in the spreadsheet, because i and j are always the same, so if you have more than one fieldName in your fieldList you will need to do something about that too. In my example, I have incremented j for each fieldName so that they will be in different spreadsheet columns
Alternative version to achieve what you ask in your comment:
假设以下文档:
解决方案1:
如果您希望结果看起来像这个
则使用以下代码:
solution 2 :如果您想要the result to look like this
Then you use the following code:
Solution 3:
如果您希望结果看起来像这样的
thirp
Lets assume the following document:
Solution 1:
If you want the result to look like this
Then you use the following code:
Solution 2: If you want the result to look like this
Then you use the following code:
Solution 3:
If you want the result to look like this
Then you use the following code:
doc.getItemvalue(cstr(b))
始终返回变体数组,即使ubound
少于一个。然后,您的
中的代码然后
条款需要放置数组的0个条目:doc.getitemvalue(CStr(b))
always returns a variant array, even when theUbound
is less than one.The code in your
Then
clause needs to dereference the 0th entry of the array: