Jump to content
Changes to the Jaspersoft community edition download ×

How to use csv metadata export


srang
Go to solution Solved by srang,

Recommended Posts

I'm working on a webportal project that will allow people to view and export reports and I would really like to make use of csv metadata export option. My problem is that although I can export the metadata from jasper studio I can't seem to get it set up on the server. I've already seen this link http://jasperreports.sourceforge.net/sample.reference/jasper/#csvmetadataexport of how to configure the reports and a simple java example but that doesn't get me very far into configuring the server to use the metadata exporter instead of the regular csv exporter. I'm using jasperreports server 6.0.1 and I've built it from source locally so if I need to do any server configuration I can. Any help would be great.

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

I love it when I get to answer my own questions haha.

Anyways, I figured out how to configure the server to use the JRCsvMetadataExporter. I basically followed the directions here, and edited the viewReportBeans.xml, using the csvexport configuration as an example but renaming things to csvmetadataexporter. Then I created a ReportCsvMetadataExporter using the ReportCsvExporter as a template, but where it used JRCsvExporter and JRCsvExporterParameter, I used the JRCsvMetadataExporter and JRCsvMetadataExporterParameter (these are the classes jasper wrote for us). And then I rebuilt the server and was able to export it fine.

So my ReportCsvMetadataExporter export method looked like:

    public void export(RequestContext context, ExecutionContext executionContext, String reportUnitURI, Map baseParameters) throws JRException {        JRCsvMetadataExporter exporter = new JRCsvMetadataExporter(getJasperReportsContext());        exporter.setParameters(baseParameters);        CsvExportParametersBean exportParams = (CsvExportParametersBean)getExportParameters(context);               if (exportParams.isOverrideReportHints()) {            exporter.setParameter(JRExporterParameter.PARAMETERS_OVERRIDE_REPORT_HINTS, Boolean.TRUE);        }               exporter.setParameter(JRCsvMetadataExporterParameter.FIELD_DELIMITER, exportParams.getFieldDelimiter());        exporter.exportReport();    }[/code]

my viewReportBeans.xml had:

    <bean id="reportCsvMetadataExporter" class="com.jaspersoft.jasperserver.war.action.ReportCsvMetadataExporter" parent="baseReportExporter">        <property name="exportParameters" ref="csvExportParameters"/>        <property name="setResponseContentLength" value="true"/>    </bean>...    <bean id="csvMetadataExporterConfiguration" class="com.jaspersoft.jasperserver.war.action.ExporterConfigurationBean">        <property name="descriptionKey" value="jasper.report.view.hint.export.csv"/>        <property name="iconSrc" value="/images/csv.gif"/>        <property name="parameterDialogName" value="csvExportParams"/>        <property name="exportParameters" ref="csvExportParameters"/>        <property name="currentExporter" ref="reportCsvMetadataExporter"/>    </bean>...        <entry key="csv" value-ref="csvMetadataExporterConfiguration"/> [/code]

This isn't perfect though as I only needed it to override the csv export and only in the web service and Jive UI. It doesn't cover scheduling or adhoc reports and doesn't necessarily play nice with those configurations either so YMMV, but hopefully this helps! and sorry it took me so long to update this

Link to comment
Share on other sites

  • 6 months later...

Hi,

I'm writing it as a comment to your post as I cannot comment your answer but I would be really interested to see the changes you made to the server.

I think we need to use the csvmetadata exporter too from the server and I'm not sure exactly of everything I need to change.

 

Link to comment
Share on other sites

  • 7 months later...
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...