PDA

View Full Version : change separator character in csv output



ulrich
02-15-2007, 10:15 AM
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

Mimil
02-15-2007, 12:31 PM
Hi,

Here is the default property defining the separator:

#
# 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).

ulrich
02-16-2007, 07:06 AM
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

Taqua
02-16-2007, 07:34 AM
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

ulrich
02-16-2007, 09:11 AM
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

nicolas_gsid
03-06-2007, 01:42 PM
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>

Taqua
03-06-2007, 02:01 PM
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

nicolas_gsid
03-07-2007, 04:37 AM
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>

ulrich
03-07-2007, 05:44 AM
try this.
You can also check against the dtd to see if your xml is correct.

Regards,
Ulrich


<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>

nicolas_gsid
03-07-2007, 02:30 PM
That's perfect thks

Taqua
03-07-2007, 03:38 PM
One final note:

JFreeReport contains two CSV output targets. Number one is the Data-CSV target. It fully ignores the report definition and exports the datarow and some status information. Due to its fixed format it is not suitable for general use - but can be useful if you need to postprocess the computed report data.

The second, more complicated output target uses the table-exporter to produce a CSV file. This mode is called "table-CSV", and depends on the layout of the report definition. If the report definition is crafted carefully, this one can be very useful, but to the novice user this may be the equivalent of 'shoting yourself in the foot'.

This is also the reason why there are two separator config-properties. The one you used initially was for the data-CSV, but aparently you used the table-CSV. And that one uses an other config-property (the one that was given in ulrich's posting).

Have fun,
said Thomas

JoséC Van
07-18-2012, 09:47 PM
Hi,

What is exactly located the File in which the
"org.jfree.report.modules.output.table.csv.Separator" must be modified; in case of wanting to do something similar to this but in Output "PDF" format, where can I change the "
org.jfree.report.modules.output.pageable.pdf.Encoding" encoding.

Please reply!
Best regards

Joséc Van

JoséC Van
07-18-2012, 09:50 PM
I'm using the Pentaho Report Designer 3.8 in the BI Server 3.9