US and Worldwide: +1 (866) 660-7555
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: change separator character in csv output

  1. #1
    Join Date
    Nov 2006
    Posts
    171

    Default change separator character in csv output

    Hi,

    can the separator character in the csv output changed from comma to tab?

    In that way the file could be opened directly with Excel.

    The xls output is not convenient in my case as the merging of cells impedes operations like ordering and we cannot ask our business users for unmerging cells.

    Thanks,
    Ulrich

  2. #2

    Default

    Hi,

    Here is the default property defining the separator:
    Code:
    #
    # Defines the column separator, defaults to comma.
    org.jfree.report.modules.output.csv.Separator=,
    So I think setting it to \u0008 should work (I didn't tested).
    May the Moo force be with you,
    Said Mimil

    A student of JFree & Pentaho Academies,
    Cedric Pronzato

  3. #3
    Join Date
    Nov 2006
    Posts
    171

    Unhappy

    Hi,

    thanks, I should have found it in the advanced reporting guide.

    However, it does not work, you get the letter u as separator. Using \t you get the letter t, not a tab.
    I don't know how it has to be escaped to appear as a tab. It should be included in the documentation.

    Thanks,
    Ulrich

  4. #4
    Join Date
    Mar 2003
    Posts
    7,969

    Default

    Hi,

    the \t or \u0008 only works in property files. If you specify the configuration in the XML file, you have to use the XML specific syntax. Use "" for a tab-character. (XML parsers really dont care about property-file or Java-syntax - these arrogant beasts only read their own entities.)

    Have fun,
    said Thomas

  5. #5
    Join Date
    Nov 2006
    Posts
    171

    Default

    I see a little square in your post, but with your hint I found that this works for me:

    <property name="org.jfree.report.modules.output.table.csv.Separator">&#x9;</property>

    Maybe it could be put into the reporting guide to save people's time.

    Thanks,
    Ulrich

  6. #6

    Default replace my csv separator

    Hi, I still hav my "," and not ";" in my reports... any idea?



    <?xml version="1.0" encoding="UTF-8"?>


    <report bottommargin="10" topmargin="10" rightmargin="10" leftmargin="10"
    height="700" width={reportWidth} name="CrossTabReport" orientation="landscape">

    <parser-config>
    <property name="org.jfree.report.modules.output.csv.Separator">&#x9;</property>
    </parser-config>

    <items color="#000000" fontname="Arial" fontsize="8" fontstyle="plain">
    {itemBand}

    </items>
    <groups>
    <group name="dummy">
    <groupheader repeat="true" color="#000000" fontname="Arial" fontsize="8" fontstyle="bold" height="20">

    <band name="DummyGroupDataBandElement">
    <rectangle color="#dff4ff" draw="false" fill="false" height="18" width="100%" x="0%" y="0"/>
    {topBand}

    </band>
    </groupheader>

    </group>
    </groups>
    </report>

  7. #7
    Join Date
    Mar 2003
    Posts
    7,969

    Default

    Hi,

    there's a huge difference between the 'parser-config' and the 'configuration' tag.

    The parser-config is used the tweak the xml-parser a bit - this allows you to replace attribute values and character data at parse time. After that, the parser-config looses its meaning. Its main purpose is to allow some basic templating (colors, fonts, etc) without having to write functions for that or doing it in code after the parsing.

    The 'configuration' however modifies the report-configuration that is assigned to each report object. The report configuration allows you to configure the behaviour of the engine and the output targets. This is what you've been looking for.

    So replace the 'parse-config' tag with a 'configuration' tag and try again.

    Have fun,
    said Thomas

  8. #8

    Default Still not working

    I tryed to use the <configuration> tag but it doesn't change anything, i still have "," as separators...
    Any idea?

    <?xml version="1.0" encoding="UTF-8"?>
    <report bottommargin="10" topmargin="10" rightmargin="10" leftmargin="10"
    height="700" width={reportWidth} name="CrossTabReport" orientation="landscape">
    <configuration>
    <property name="org.jfree.report.modules.output.csv.Separator">&#x9;</property>
    </configuration>


    <items color="#000000" fontname="Arial" fontsize="8" fontstyle="plain">
    {itemBand}
    </items>
    <groups>
    <group name="dummy">
    <groupheader repeat="true" color="#000000" fontname="Arial" fontsize="8" fontstyle="bold" height="20">

    <band name="DummyGroupDataBandElement">
    <rectangle color="#dff4ff" draw="false" fill="false" height="18" width="100%" x="0%" y="0"/>
    {topBand}

    </band>
    </groupheader>

    </group>
    </groups>
    </report>

  9. #9
    Join Date
    Nov 2006
    Posts
    171

    Default

    try this.
    You can also check against the dtd to see if your xml is correct.

    Regards,
    Ulrich
    Code:
        <report-config>
            <simple-page-definition width="1" height="1">
                <page orientation="portrait" topmargin="20" leftmargin="20" bottommargin="20" rightmargin="20" pageformat="A4"/>
            </simple-page-definition>
    				<configuration>
    				<property name="org.jfree.report.modules.output.table.csv.Separator">;</property>
    				</configuration>
        </report-config>

  10. #10

    Thumbs up working

    That's perfect thks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •