Populate a listbox for printing

My app creates a listbox which I wish to print using the report mechanism. Tried to follow the example (which works) but cannot see how the listbox got populated. Every thing I try gets unhelpful error messages: eg type mismatch error expected int32 but got boolean; expected string but got string; desktoplistbox has no member named “ListIndex”.
Suspect I have fallen foul of the deprecation process somewhere along the way.
So if that is a problem I am going to have to revert to ListBox (how?).
If that sorts out some of the problems then How do I establish my listbox as a dataset usable by the report writer.
Please don’t tell me to use a DB - I must stick with my csv data.

Stick with DesktopListbox.

Showing us your code would be a start. Even better would be to post your project so one can see what is happening.

Did you find the documentation for the DataSet interface?

OK… But but let me just point out writing code to generically import CSV data into a created on the fly temporary in memory SQLite database that is never written to disk, would not be difficult and could offer a lot of capabilities/flexibility in general.

-Karen

5 Likes

Sounds as tho it meets my objectives but my investigations into sqlite don’t look all that promising. Can you reassure me by making it look easy?
I have solved my troubles with deprecated listboxes by going back to earlier version

Learning to use the Xojo Database API and Sqlite specifically will help you a lot in the long run… I would strongly advise it.

In any case my suggestion to use SQLite when loading your CSV files is independent of the listbox, or printing. It makes pulling data out and grouping and organizing it a breeze… once you learn SQLite

-Karen

BTW I never used Xojo Reporting and always have just coded my own reports…

1 Like

Interesting. Can I ask, Karen, how you coded your own stuff for printing? Did you create a canvas of the right size and insert stuff into that, or perhaps even just a window? If so what do the actual print commands look like?

I have used canvases and just the basic print commands. I have code that will wrap text, control justification and line spacing and truncate if needed…

For tables I just drew them using basic drawing commands…

I actually wrote code man years ago to print REALBasic list boxes that way… but I moved away from that long ago.

For many years now, I have been just been creating PDFs. Originally I did that using some open source Xojo PDF classes, then the Einhugur PDF plugin…

I wrote a quick table function to write the PDF code to draw tables, similar in concept to a Xojo Listbox.

A PDF is easy to email or the app can launch it and let the user print it if they want…

For my use cases PDF was the most convenient. More coding than with a report generator, but also more control… Being I was doing technical reports with lot of tables, graphs and chemical structures, it seemed best to me. Many of those reports were quite long (50-100 pgs) and had clickable table of contents and internal hyperlinks for ease of use.

These days that could likely be done with the new built in PDF functionality, though I have have not used it and stayed with the Einhugur plugin and my code.

BTW can Xojo Report engine produce PDF’s with Table of contents and hyperlinks? I know XOJO PDF supports TOC but I don’t know of it is integrated into the reports generator, having not used it.

-Karen

Wow! Gives me a lot to think about! My solution is clunky but it works: I create a csv file which I import into an Excel document - takes advantage of XLs formatting and printing. Was not without having to overcome/get round XL glitches but perseverance won the day. From my rudimentary grasp of the PDF facilities (plugin or builtin) that too can be tedious. I shall continue to poke around while sticking with XL for the time being.
Thank you for your help - much appreciated.

There is also an Einhugur ExcelWriter plugin that I use a lot to export WebListboxes to an Excel file for downloads. Very easy to use and much easier on the user than having to open a csv file in Excel.

Thanks, Tom, but the Xojo code to create a csv file from a listbox is very easy and compact. Importing into an XL spreadsheet involves a few clicks but is not that much of a bother. If I am importing into an XL sheet that has been copied from a template for which I have created suitable macro(s) then it is only a one click job. I’ll stick.