Listbox with more than 64 columns?

The docs state "The maximum number of visible columns is 64 " which isn’t a huge problem, but I have a listbox with 167 columns and when I try to save it as a tab-delimited text file use the old faithful:

  Dim excelOut As TextOutputStream
  
  Dim dlg as New SaveAsDialog
  Dim f as FolderItem
  
  dlg.InitialDirectory=SpecialFolder.Desktop
  dlg.promptText="Save Text As"
  dlg.SuggestedFileName="My Text Out.txt"
  dlg.Title="Text Output"
  
  f=dlg.ShowModal()
  
  If f <> Nil then
    excelOut = TextOutputStream.Create(f)
    if excelOut <> nil then
      excelOut.Write ComposerStatementList.Heading(-1)
      excelOut.Write CHR(9)+CHR(13)
      excelOut.Write ComposerStatementList.cell(-1,-1)
      excelOut.Close
    end if
  Else
    //user canceled
  End if

it only exports the first 64 columns. Anyone know a workaround?

I would suggest NOT using (-1,-1) and iterate over the RowCount and ColumnCounts instead

Cheers Dave I’ll give that a go.

My guess us you DON’T have a Listbox with 167 columns, but a normal LisBox with 64 column and a data structure with 167 colums that fills the Listbox as required.

So obviously you then need to export the data structure and not the Listbox.

Use Einhugur’s StyleGrid.

Cheers Dave - this worked (but sadly not for the headers but I can live with that on this occasion)

      for r = 0 to SMListBox.ListCount - 1
        for c = 0 to 166
          excelOut.Write SMListBox.cell(r,c)
          excelOut.Write CHR(9)
        next c
        excelOut.Write CHR(13)
      next r
      
      excelOut.Close

DO YOU KNOW ABOUT:

WriteLine "text data to write to disk" // ?

Also, do you know:

WriteLine "text data to write to disk" + Chr(9) + "A Second Column…" // ?

And for the Headers, scan them and write them do disk (or better, save the real string used to set the Headers)…

[quote=199129:@Emile Schwarz]DO YOU KNOW ABOUT:
And for the Headers, scan them and write them do disk (or better, save the real string used to set the Headers)…[/quote]

This did the trick for me (I’d entered them in the Inspector)

      excelOut.Write SMListBox.InitialValue
      excelOut.Write CHR(9)
      excelOut.Write CHR(13)

Doh ! I would not think at that at all !

But you still can write it like below:

excelOut.WriteLine SMListBox.InitialValue

Check that in TextOutputStream.WriteLine and if by bad luck, this does not made the trick, you can change the Delimiter property ONCE, then use the standard WriteLine.
This is just one line, one clear line instead of three.

At last, I do that and you are free to code as you want.

BTW: I just realize: you end your saved line with a Tab + a Return ?

What for ?

[quote=199139:@Emile Schwarz]
BTW: I just realize: you end your saved line with a Tab + a Return ?

What for ?[/quote]

The txt file wasn’t importing properly to Excel (Mac) without it.

Thanks for the WriteLine tips btw - haven’t done much with TextOutputStream before.

Thanks.

It was more than 20 years that I do not fired (run) Excel… anywhere) ;-:slight_smile: