Jump to content

Recommended Posts

Posted

Hi all,

Jasper studio version 6.3.1

Jasper server version 6.3.0

I am facing problem to override the sheet name based on parameter it receives. I know people have posted this question before and the solution is to use this property net.sf.jasperreports.export.xls.sheet.name but on which element I should implement this property. Please help me over this and also is there any way to change the file name dynamically as well.

Thanks in advance.

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted

check the below jrxml.

The documentation mentioned that the last element to be rendered with this property value will become the sheet name.

so i have placed the property on a text field inside the detail band.

http://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.export.xls.sheet.name

 

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0  --><!-- 2017-05-10T12:52:05 --><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="printSheetName" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b6735bd2-5665-45f8-86c7-02b39d58c5f2">    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>    <parameter name="SheetName" class="java.lang.String"/>    <queryString>        <![CDATA[select * from dual]]>    </queryString>    <field name="DUMMY" class="java.lang.String"/>    <background>        <band splitType="Stretch"/>    </background>    <columnHeader>        <band height="30" splitType="Stretch">            <staticText>                <reportElement x="0" y="0" width="100" height="30" uuid="fc5b9b93-e496-4cac-903c-748cb3e3bcbf"/>                <text><![CDATA[DUMMY]]></text>            </staticText>        </band>    </columnHeader>    <detail>        <band height="30" splitType="Stretch">            <textField>                <reportElement x="0" y="0" width="100" height="30" uuid="c59d9bdd-8524-4b14-ba30-5a833f72a1bc">                    <propertyExpression name="net.sf.jasperreports.export.xls.sheet.name"><![CDATA[$P{SheetName}]]></propertyExpression>                </reportElement>                <textFieldExpression><![CDATA[$F{DUMMY}]]></textFieldExpression>            </textField>        </band>    </detail></jasperReport>[/code]

 

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