Jump to content

RTF exporting problem


manishp2002in

Recommended Posts

 i am using jasper reports 3.6.0 jar for exporting to RTF file ,report is generated succesfully.

But the real problem is that when file is opened in ms word all the values are in separate text box  which cannot be selected with mouse for editing.Is this a bug or i am doing anything wrong while generating.

I am using yhis code to generate RTF file 

 

JasperPrint jasperPrint = JasperFillManager.fillReport(reportFile.toString(), parameters,conn);

File destFile = new File(file_path, request.getParameter("Report_type") + ".rtf");

                System.out.println("destfile"+destFile.toString());

JRRtfExporter exporter = new JRRtfExporter();

                  exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());

exporter.exportReport();

 

Code:
<?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Vancouver_REPORT" pageWidth="595" pageHeight="842" columnWidth="575" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10" whenResourceMissingType="Empty">	<property name="ireport.scriptlethandling" value="0"/>	<property name="ireport.encoding" value="UTF-8"/>	<import value="java.util.*"/>	<import value="net.sf.jasperreports.engine.*"/>	<import value="net.sf.jasperreports.engine.data.*"/>	<parameter name="company_name" class="java.lang.String">		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>	</parameter>	<parameter name="Address" class="java.lang.String">		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>	</parameter>	<parameter name="Query" class="java.lang.String">		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>	</parameter>	<parameter name="order_by_1" class="java.lang.String">		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>	</parameter>	<parameter name="order_by_2" class="java.lang.String">		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>	</parameter>	<parameter name="order_by_3" class="java.lang.String">		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>	</parameter>	<parameter name="order_by_4" class="java.lang.String">		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>	</parameter>	<queryString>		<![CDATA[select i.Info_ID,COALESCE(Authors,'')+' ( '+cast(year as varchar)+')'+COALESCE(title,'')+'. '+Journal_Name+''+COALESCE( Volume,'')+':'+COALESCE(Issued,'')+':'+COALESCE(Page_From,'')+' - '+COALESCE(Page_To,'') as a, Formulae,Verified_On,Verified_Byfrom Journals j,Information i join ($P!{Query}) as t on( i.Info_ID=t.info_id)  where i.Journal_Code=j.Journal_ID $P!{order_by_1}$P!{order_by_2} $P!{order_by_3} $P!{order_by_4}]]>	</queryString>	<field name="Info_ID" class="java.lang.Integer">		<fieldDescription><![CDATA[]]></fieldDescription>	</field>	<field name="a" class="java.lang.String">		<fieldDescription><![CDATA[]]></fieldDescription>	</field>	<field name="Formulae" class="java.lang.String">		<fieldDescription><![CDATA[]]></fieldDescription>	</field>	<field name="Verified_On" class="java.lang.String">		<fieldDescription><![CDATA[]]></fieldDescription>	</field>	<field name="Verified_By" class="java.lang.String">		<fieldDescription><![CDATA[]]></fieldDescription>	</field>	<group name="f">		<groupExpression><![CDATA[$F{Formulae}]]></groupExpression>		<groupFooter>			<band splitType="Stretch"/>		</groupFooter>	</group>	<background>		<band splitType="Stretch"/>	</background>	<title>		<band height="45" splitType="Stretch">			<textField isBlankWhenNull="false">				<reportElement key="textField" x="10" y="0" width="549" height="15"/>				<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>				</box>				<textElement textAlignment="Center">					<font size="10" isBold="true"/>				</textElement>				<textFieldExpression class="java.lang.String"><![CDATA[$P{company_name}]]></textFieldExpression>			</textField>			<textField isBlankWhenNull="false">				<reportElement key="textField" x="10" y="15" width="549" height="15"/>				<box>					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>				</box>				<textElement/>				<textFieldExpression class="java.lang.String"><![CDATA[$P{Address}]]></textFieldExpression>			</textField>			<staticText>				<reportElement x="227" y="30" width="100" height="15"/>				<textElement textAlignment="Center">					<font isBold="true" isUnderline="true"/>				</textElement>				<text><![CDATA[JNR Style]]></text>			</staticText>		</band>	</title>	<pageHeader>		<band splitType="Stretch"/>	</pageHeader>	<columnHeader>		<band splitType="Stretch"/>	</columnHeader>	<detail>		<band height="29" splitType="Stretch">			<elementGroup>				<textField isBlankWhenNull="false">					<reportElement key="textField" x="0" y="0" width="34" height="15"/>					<box>						<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>						<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>						<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>						<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>					</box>					<textElement textAlignment="Right"/>					<textFieldExpression class="java.lang.String"><![CDATA[$V{REPORT_COUNT}.toString().concat(")")]]></textFieldExpression>				</textField>				<textField isStretchWithOverflow="true" isBlankWhenNull="true">					<reportElement key="textField" x="35" y="0" width="525" height="15" isRemoveLineWhenBlank="true"/>					<box>						<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>						<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>						<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>						<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>					</box>					<textElement/>					<textFieldExpression class="java.lang.String"><![CDATA[$F{a}]]></textFieldExpression>				</textField>			</elementGroup>		</band>		<band/>	</detail>	<columnFooter>		<band splitType="Stretch"/>	</columnFooter>	<pageFooter>		<band height="20" splitType="Stretch">			<staticText>				<reportElement x="10" y="0" width="73" height="15"/>				<textElement/>				<text><![CDATA[Printed On:]]></text>			</staticText>			<textField pattern="dd/MM/yyyy">				<reportElement x="83" y="0" width="100" height="15"/>				<textElement/>				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>			</textField>			<textField>				<reportElement x="423" y="0" width="80" height="15"/>				<textElement textAlignment="Right"/>				<textFieldExpression class="java.lang.String"><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>			</textField>			<textField evaluationTime="Report">				<reportElement x="503" y="0" width="40" height="15"/>				<textElement/>				<textFieldExpression class="java.lang.String"><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>			</textField>		</band>	</pageFooter>	<summary>		<band splitType="Stretch"/>	</summary></jasperReport>
Link to comment
Share on other sites

  • 1 year later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • 10 months 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...