Is there a way to set xcel output sheet name?

0

when you open the spreadsheet, its name is the sheet name.  I'd like to set the sheet name to the date of creation.

patricia.williams's picture
Joined: Mar 8 2015 - 7:57am
Last seen: 2 years 1 month ago

2 Answers:

0

Sheet name can be set type setting them in property "net.sf.jasperreports.export.xls.sheet.name". Following page shows how to set it dynamically:

http://community.jaspersoft.com/wiki/excel-export-dynamically-set-sheet-...

hozawa's picture
64916
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 year 3 months ago
1

That link hints that you can use net.sf.jasperreports.export.xls.sheet.name to obtain that, but does not really explain how.

A little trial&error testing in Jasper Studio 6.4.0.final using a simple report with column header and detail band, revealed that JS was very picky about where to place it. I could only get it to work if I placed it inside a reportElement:

<detail>
        <band height="14" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="70" height="14" uuid="e0777908-52d5-4c52-8fb3-fcb3c31633bb">
                    <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    <propertyExpression name="net.sf.jasperreports.export.xls.sheet.name"><![CDATA[$V{SheetDetail}]]></propertyExpression>
                </reportElement>
                <textFieldExpression><![CDATA[$F{REP_AAR}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="70" y="0" width="85" height="14" uuid="b0d57d3b-0c00-4eb2-a106-d845732c8015"/>
        

$V{SheetDetail} is just a variable I created to hold the name of the sheet. It could also be a field. 

Furthermore, it did not matter in which field i placed the "sheet name", so I just placed it in the first field.

lbor's picture
17
Joined: Feb 22 2017 - 12:23am
Last seen: 7 months 2 weeks ago
Feedback