Reputation: 23
I am writing an export to excel from any view. There are many samples available and works on "normal views". As soon as I have a view with a column with a static value it gets skipped.
I have a view with 4 columns, 1,3 and 4 are linked to fields on the document and column 2 are only a numeric 2.(I have tried "2" and 2) (This is a test view)
C1 | V2 | C3 | C4 columns
1 | 2 | 3 | 4 values
'This gets all 4 column names
ForAll n In view.Columns
cNames(columnTotal) = n.title
columnTotal = columnTotal + 1
End ForAll
'Result
'cName(0) = "C1"
'cName(0) = "V2"
'cName(0) = "C3"
'cName(0) = "C4"
'This gets only 3 column values
Set nav = view.createviewnav
Set entry = nav.Getfirst()
While Not entry Is Nothing
ForAll c In view.Columns
readvalue = entry.Columnvalues(columncounter-1)
End ForAll
Wend
'Result
'entry.columnvalues(0) = "1"
'entry.columnvalues(1) = "3"
'entry.columnvalues(2) = "4"
I can't post a screenshot, this is my 1st posting, but it shows that the entry.columnvalues contains 3 values but the parent.columns(Notesviewcolumn()) of the entry shows 4 column names ...
How can I read all the values displayed in a view, including values that does not exist on the underlying document ?
Thank you.
Upvotes: 2
Views: 457
Reputation: 30970
Documentation tells for entry.ColumnValues
A column value is not returned if it is determined by:
- A formula containing a UI-only function such as @IsExpandable or @DocNumber.
- A constant.
According to a blog from Dmytro Pastovenskyi you can use ColumnValuesIndex
though to recognize if a column is a constant or a formula containing a UI-only function.
Export only columns which have a ColumnValuesIndex
>= 0:
ForAll n In view.Columns
If n.ColumnValuesIndex >= 0 Then
cNames(columnTotal) = n.title
columnTotal = columnTotal + 1
End If
End ForAll
Upvotes: 1