Excel Group by and Outline in Jasper Reports

I am using Jasper Reports to export to Excel and I want to know if it's possible to export a spreadsheet with grouping.

I mean, create a report in jasper with data already grouped so that when I open it on excel I can use the +/- buttons to expand/collapse them.

Answers


Yes, you can do it with help of net.sf.jasperreports.export.xls.row.outline.level.{n} property.

The information about export to Excel features is here.

You can examine the sample in JasperReports package, in *$jasperreports_folder$\demo\samples\xlsfeatures* folder.

The sample:

<group name="citygroup">
    <groupExpression><![CDATA[$F{city}]]></groupExpression>
    <groupHeader>
        <band height="20">
            <textField>
                <reportElement x="0" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA["City: " + $F{city}]]></textFieldExpression>
            </textField>
        </band>
    </groupHeader>
    <groupFooter>
        <band height="21">
            <textField>
                <reportElement x="0" y="1" width="100" height="20">
                    <!-- Outline row group ends here-->
                    <property name="net.sf.jasperreports.export.xls.row.outline.level.1" value="End"/>
                </reportElement>
                <textElement/>
                <textFieldExpression><![CDATA["Total: " + $V{citygroup_COUNT}]]></textFieldExpression>
            </textField>
        </band>
    </groupFooter>
</group>
<detail>
    <band height="20" splitType="Stretch">
        <textField>
            <reportElement x="0" y="0" width="100" height="20">
                <!-- Outline row group starts here-->
                <property name="net.sf.jasperreports.export.xls.row.outline.level.1" value="Body"/>
            </reportElement>
            <textElement/>
            <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="100" y="0" width="100" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="200" y="0" width="100" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
        </textField>
    </band>
</detail>
Limitation:

This sample works properly (export to xls via preview function) in iReport 4.1.3 version, but not in 4.1.2 version. May be this is a new feature of 4.1.3 version (see release notes).


Need Your Help

HtmlAgilityPack select data from sub-node

c# html linq parsing html-agility-pack

I have the following HTML code I'd like to parse:

How to attach stylesheet to HTML email?

html css email

I want to include normalize.css in a HTML email. However various tutorials advise that all css should be inline, as some email clients ignore linked styles in the head. In such case how can I include

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.