Forums

Find answers, ask questions, and connect with our
community all around the world.

Home Forum Omnis General Forum Export to a file-issues

  • Export to a file-issues

    Posted by Uwe Smidt on November 22, 2023 at 12:52 am

    Dear $all,

    I would like to export list data into a file.

    a) is there a (platform-independant) way to export to Excel?

    b) I’d like to include a header line with my data.

    With myList.$cols.$makelist($ref.$name) returns llHeader I get the the Column names, 1 list line per column. Is there a <b style=”font-family: inherit; font-size: inherit;”>simple command to transpose this list into a row, so I can use it as the header line? The following is very clumsy:

    Do llHeader.$first()
    While llHeader.$line
    Do llHeader2.$addcols(llHeader.C1,kCharacter,kSimplechar,255)
    Do llHeader2.[llHeader.C1].$assign(llHeader.C1)
    Do llHeader.$next(llHeader.$line)
    End While

    But this did not work:

    Do llHeader.$sendall(llHeader2.$addcols($ref.$name,kCharacter,kSimplechar,255))

    c) when I export into a file using

    Set print or export file name [lcPath]
    Prepare for export to file Delimited (tabs)
    Export data llHeader2
    Export data ilDataList
    End export
    Close print or export file

    the numerical values use a ‘.’ for the <em style=”font-family: inherit; font-size: inherit;”>decimal and a ‘,’ for the thousand separators – I need it the other way around. Is there a setting to correct this (My system is German localized, i.e. ‘,’ for the <em style=”font-family: inherit; font-size: inherit;”>decimal and a ‘.’ for the thousand separators)

    Thanks in advance!

    Uwe

    Uwe Smidt replied 3 months ago 3 Members · 7 Replies
  • 7 Replies
  • Andreas Pfeiffer

    Administrator
    November 22, 2023 at 8:08 am

    Hi Uwe,

    You might want to look at a technical note I wrote a while ago. It provides a tool that generates a CSV file for the client by a given list variable. https://www.omnis.net/developers/resources/technotes/tnjs0011.jsp

    CSV is a standard that should be easy to import in Excel or Numbers.

    Hope this helps.

    Best,

    Andreas

    • Uwe Smidt

      Member
      November 29, 2023 at 9:29 am

      Dear Andreas,
      Thank you for your great sample – I have integrated it into my library, and it works fine!

      Best regards
      Uwe

      • Andreas Pfeiffer

        Administrator
        November 29, 2023 at 9:57 am

        Great! I am glad it works for you.

        Best,

        Andreas

  • Joey Tribbiani

    Member
    November 22, 2023 at 2:22 pm

    Hi Uwe!

    For “a)” I would as Andreas suggested use a CSV conversion. So probably the CSV-Conversion done as in the technical note would solve all your stated problems.

    Anywho… I got a bit curious, why the list entries to row conversion does not work out for you. So I gave it a try. But the weird thing is, that I’ve got it working just right – immediately. – So I had a look at your code again.

    And there it is. So the error is actually in your code. So to make it short:

    – Replace the … .$addcols() … function with $cols.$add()

    – And also use $sendallref.$name in the $add() function. Because $ref will not work in this scope

    I’ve tinkered a little sample app for this just for fun. So if you wanna have look – see the library in the attachment.

    Note: When I’ve got the time for it, I will also convert the library into a CE one – so everyone in this forum can have a look at it.

    Have a good one!

    • Joey Tribbiani

      Member
      November 22, 2023 at 2:28 pm

      Edit: I’ve forgot to mention that I would and will also work with the used $addcols() function, if you just wanna replace the $ref with $sendallref. But I suggest to also change $addcols() to $cols.$add() because this is the “right way” of doing it.

      This because $sendall() is nothing else than a loop but much more efficient. So it will iterate through the lines of the list and insert a new column for every line, and it will call the $addcols() function for every singe line. This will result in a $addcols function being used for only one column at a time, which is not the real purpose of the $addcols function. In the case of just adding one column it is better and more clean to use the $cols.$add.

      Joey

      • Uwe Smidt

        Member
        November 30, 2023 at 2:50 pm

        Dear Joey,

        Thank you for your elaborate answer (including a great sample lib!) – so elaborate that it took me a while to evaluate ­čśë

        But now I did – and yes, you are right, $sendallref does the trick!

        Do ilExportList.$define() ## clear definition
        Do ilExportList.$add()
        # Alter, funktionierender Code ohne $Sendall:
        # For ilColList.$line from 1 to ilColList.$linecount step 1 ## f├╝r alle Spalten...
        # If ilColList.export ## NUR die markierten Spalten...
        # Do ilExportList.$cols.$add(ilColList.colname,kCharacter,kSimplechar,255) ## kommen in die Spalten├╝berschriften
        # Calculate ilExportList.1.[ilColList.colname] as ilColList.title
        # End If
        # End For
        Do ilColList.$sendall(ilExportList.$cols.$add($sendallref.colname,kCharacter,kSimplechar,255),$ref.export) ## ACHTUNG: hier $sendallref erforderlich, da mit ...$add eine Untermethode mit Parameter aus der ├ťbermethode ...$sendall aufgerufen wird. Nur so wird der Parameter korrekt ├╝bergeben (byValue vs byRef)
        Do ilColList.$sendall(ilExportList.1.[$ref.colname].$assign($sendallref.title),$ref.export)

        Because in ilExportList.$cols.$add($sendallref.colname<font face=”inherit”> the $add sends </font>the<font face=”inherit”> parameter into another method, which is why $ref’s by Value does not work, but $sendallref’s by reference does! </font>

        <font face=”inherit”>Thank you for your help in grasping an important difference!</font>

        <font face=”inherit”>Best regards</font>

        <font face=”inherit”>Uwe</font>

  • Uwe Smidt

    Member
    November 30, 2023 at 2:56 pm

    issue c) is still unsolved (probably because of this forum software’s tendency to ‘beautify’ paragraphs after ‘preformatted text’ (code blocks etc)):

    How do I kindly ask Omnis to stick to system wide preferences regarding the formatting of numbers, i.e. comma as decimal separator, point as thousands separator?

Log in to reply.