首页 > 解决方案 > 如何在 excel 导出中冻结第二张工作表的第一行?

问题描述

我试图从碧玉报告中冻结我的 excle 导出的第二张表上的第一行,但它冻结了另一行。在我下面的示例代码中,它冻结了第二张纸上的前两行,但如果第一张纸上有更多行,第二张纸上冻结的行数会更高。似乎它在第二张纸上“添加”了第一张纸上的行数,所以如果第一张纸上有 9 行并且我尝试冻结第二张纸上的第一行,它会冻结第 10 行在我的第二张纸上排。这是 jasper-reports 中的错误还是我在这里做错了什么?有谁知道如何以另一种方式解决这个问题?

<?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="RowBreakTest" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0292da25-2332-41a0-8f81-fcbe04339e99">
    <title>
        <band height="28">
            <staticText>
                <reportElement x="0" y="0" width="280" height="14" />
                <text><![CDATA[This is just the first sheet]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="14" width="280" height="14" />
                <text><![CDATA[]]></text>
            </staticText>
            <staticText>
                <reportElement x="280" y="0" width="270" height="14" />
                <text><![CDATA[]]></text>
            </staticText>
            <staticText>
                <reportElement x="280" y="14" width="270" height="14" />
                <text><![CDATA[]]></text>
            </staticText>
        </band>
    </title>
    <columnHeader>
        <band height="14" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="280" height="14">
                    <property name="net.sf.jasperreports.export.xls.break.before.row" value="true"/>
                    <property name="net.sf.jasperreports.export.xls.freeze.column.edge" value="Left"/>
                </reportElement>
                <text><![CDATA[header on 2nd sheet]]></text>
            </staticText>
            <staticText>
                <reportElement x="280" y="0" width="270" height="14">
                    <property name="net.sf.jasperreports.export.xls.freeze.row.edge" value="Bottom"/>
                </reportElement>
                <text><![CDATA[more header on 2nd sheet]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="28" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="280" height="14" />
                <text><![CDATA[data]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="14" width="280" height="14" />
                <text><![CDATA[more data]]></text>
            </staticText>
            <staticText>
                <reportElement x="280" y="0" width="270" height="14" />
                <text><![CDATA[even more data]]></text>
            </staticText>
            <staticText>
                <reportElement x="280" y="14" width="270" height="14"/>
                <text><![CDATA[a lot more data]]></text>
            </staticText>
        </band>
    </detail>
</jasperReport>

标签: jasper-reportsexport-to-excel

解决方案


推荐阅读