CSV output in SQR

I don’t get to code much SQR in my current job, this is something new I learned recently.

Do you know that SQR supports writing CSV reports using its print command? In the column number, specify the column number as it will be displayed in Excel. For example, a 3-column sheet, the SQR code looks like this:


   print "Column 1" (1,1)
   print "Column 2" (,2)
   print "Column 3" (,3)

   print $line1a    (+1,1)
   print $line1b    (,2)
   print $line1c    (,3)

   print $line2a    (+1,1)
   print $line2b    (,2)
   print $line2c    (,3)

SQR takes care of the formatting if the value being printed contains embedded commas and quotes. To instruct SQR to print in CSV mode, the -EH_CSV should be added to the SQR command-line parameters. In Process Scheduler, it adds this parameter if you choose CSV as the output format.

13 thoughts on “CSV output in SQR

  1. This is not working. I tried printing two different columns but they are overlapping.
    Are the print commands correct?

    Can you give me some woring code. I need it urgently…

    Regards
    Abhinav

  2. Abhinav, are you sure you’re running your SQR program with -EH_CSV command line parameter? Also, what version of SQR are you running? The feature is only available in versions 4.3.1 up.

  3. Hi

    I have a problem in a CSV file, generated with SQR. A data is too large (more than 200 characters). It fills a cell, but the next datas of the same line have to be set a line under (but they keep the same column)

    Is there a way to control data length on an Excel cell, using a SQR function ?

    Thanks in advance.

  4. Hi,

    Can we do cell formatting in a csv file using sqr? Like, i would like some cells to be merged, some cells to have a background colour, some text to be bolded etc.

    Thanks in advance

  5. ChilliJoe,
    We can use HTML tags in SQR to write an xls file.

    Open $filename as 2 for-writing record=20000 status=#filestat2
    Write 2 from ”
    Write 2 from ”
    Write 2 from ”
    Write 2 from ‘Heading1′
    Write 2 from ”
    Write 2 from ”
    Write 2 from ‘Heading2′
    Write 2 from ”

    !Select data in begin select and write it
    write 2 from ”
    write 2 from ”
    write 2 from $selected variable
    write 2 from ”
    write 2 from ”

    Write 2 from ”
    Close 2

    We can use the same approach to write an xls file in app engine peoplecode. I think we can use HTML tag properties for , also.

  6. I was talking about html tags like table , tr , th and td .

    we have to give the complete tag as a string
    “”
    “”
    “”

  7. SQR is the MOST SUCK program i meet.

    Frankly, if you use “write” function you can edit your delimeter if you output your file as CSV, handy while you have “comma” inside your data to output. But you wont be able to edit mask feat, so whenever you need to write a “2.00″ float as “2″ integer to file, you need to

    1. assign float > integer
    2. move integer to string var
    3. write out your string var by using “write” command,

    it’s like hell when you have over 10 integer to writeout for each row

    if you use Print command you can save the 3 steps above by

    Print #my_integer (, +1) 999

    But….
    if your row has a cell with “comma” value
    E.g. a cell “Dept, Section”

    Then you will doom coz YOU WILL NEVER ABLE TO CUSTOM YOUR DELIMETER in CSV, YOU ARE FORCE TO USE “,” comman

    Till now i cant find the solution

  8. I want to format the text in the output csv of the sqr.
    Exactly,i want to bold the text.
    Can anybody help me regarding this.

  9. I believe you cannot do any formatting with csv such as bold, italic, highlight etc. You can do merging manually (not thru sqr since I haven’t tried this one and hoping someone will enlighten us if it is possible to merge cells using sqr. Also, I am using the sylk.sqc and I didn’t see any merge procedure there).

  10. Hi, if we use print command in sqr, wll it cause any problems in csv file generated.For me,commas are missing for certain rows when i open csv, but pdf is working fine.I use on-braek along with print command

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>