2

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.

Johan
  • 23
  • 5

1 Answers1

1

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
Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • 1
    Thank you for the quick response. I looked at Dmytro Pastovenskyi's blog and it is very usefull but I made one small change. In my case it also skipped the 1st column that was just a field value, no formula and not hidden but returned an index of 0. My code that build's the column names list 1st, looks like this and I get my result that I want for now, will test more on other views and give feedback. ForAll n In view.Columns If Not(n.ColumnValuesIndex = -1) Then cNames(columnTotal) = n.title columnTotal = columnTotal + 1 End If End ForAll – Johan Jul 10 '15 at 14:22
  • You are right: 0 is a valid value for a real column, so `> 0` has to be `>= 0`. I changed my code. – Knut Herrmann Jul 10 '15 at 14:25