2011-12-21 7 views
0

に渡されたパラメータを使用して、Excelのセルサイズを固定し、私は以下のようにマップに文字列として二つの日付を設定しています:いくつかのクエリ - jrxml

Map<String, String> hashmap = new HashMap<String, String>(); 
hashmap.put("date1", date1); 
hashmap.put("date2", date2); 

この私は以下のように使用しています:

JasperReport jasperReport1 = JasperCompileManager.compileReport(this.reportName1); 
JasperPrint jasperPrint1 = JasperFillManager.fillReport(jasperReport1, hashmap, con); 
jprintList.add(jasperPrint1); 

1)この渡されたパラメータをJRXMLファイルで使用する方法。

基本的には、日付2の列、つまり日付1の列1と日付2の列2を比較しています。

したがって、これらの日付の値を列見出しに使用したいと考えています。

<columnHeader> 
    <band height="11"> 
    <rectangle> 
     <reportElement x="0" y="0" width="920" height="11" backcolor="#333333"/> 
     <graphicElement/> 
    </rectangle> 
    <staticText> 
    <reportElement mode="Opaque" x="20" y="0" width="80" height="11" forecolor="#ffffff" backcolor="#333333" style="Arial_Bold"/> 
     <textElement textAlignment="Left"/> 
     <text><![CDATA[Column for <here should come date1>]]></text> 
    </staticText> 
     <staticText> 
    <reportElement mode="Opaque" x="20" y="0" width="80" height="11" forecolor="#ffffff" backcolor="#333333" style="Arial_Bold"/> 
     <textElement textAlignment="Left"/> 
     <text><![CDATA[Column for <here should come date2>]]></text> 
    </staticText> 
    </columnHeader> 

日付値は、上記のコードでは、「代わりに使用される。

2)列のタイトルを構成するテキストをラップする方法?

私はExcelでレポートをエクスポートしています。

私は、タイトルが有益であるように、「12/12/2011の価格を表示する列」というタイトルを持っています。これは、長いタイトルの列が合計13列あるのでかなり長いです。

テキストをラップする方法、またはExcelの列タイトルのセルサイズを修正する方法。

JRXMLでどのような変更を行う必要がありますか?

3)私はjprintlistでいくつかのレポートを渡しています。各レポートは、最終的なExcelファイル内の別々のワークシートに掲載されています。ワークシートに名前を付けるには?デフォルトでは、タグからjasperReportのname属性を受け取り、最後に1,2を追加します。

回答:読書のための本

exporter.setParameter(JRXlsExporterParameter.SHEET_NAMES, new String[]{”Personal Information”, “Skills”}); 

おかげへの答えを手に入れました!

答えて

1

1)このパラメータをJRXMLファイルで使用する方法。

あなたはパラメータを使用するための$P{}表現を使用することができます。サンプル:

<text><![CDATA[Column for $P{date}]]></text> 

2)列のタイトルを構成するテキストをラップする方法は?

あなたはタイトルが成長できるようにisStretchWithOverflowstretchTypeを使用することができます。

サンプル:

<columnHeader> 
    <band height="20" splitType="Stretch"> 
     <textField isStretchWithOverflow="true"> 
      <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="100" height="20"/> 
      <box leftPadding="5"> 
       <topPen lineWidth="1.0"/> 
       <leftPen lineWidth="1.0"/> 
       <bottomPen lineWidth="1.0"/> 
       <rightPen lineWidth="1.0"/> 
      </box> 
      <textElement/> 
      <textFieldExpression><![CDATA["Column for " + $P{title1}]]></textFieldExpression> 
     </textField> 
     <textField isStretchWithOverflow="true"> 
      <reportElement stretchType="RelativeToTallestObject" x="100" y="0" width="100" height="20"/> 
      <box leftPadding="5"> 
       <topPen lineWidth="1.0"/> 
       <leftPen lineWidth="1.0"/> 
       <bottomPen lineWidth="1.0"/> 
       <rightPen lineWidth="1.0"/> 
      </box> 
      <textElement/> 
      <textFieldExpression><![CDATA["Column for " + $P{title2}]]></textFieldExpression> 
     </textField> 
    </band> 
</columnHeader> 

結果は(Excelのプレビュー)になります。

enter image description here

あなたはまた、net.sf.jasperreports.export.xlsを設定してみてください。 wrap.textプロパティtextField要素。あなたはこの物件hereについて読むことができます。

サンプル:

<textField> 
    <reportElement x="100" y="0" width="100" height="20"> 
     <property name="net.sf.jasperreports.export.xls.wrap.text" value="false"/> 
    </reportElement> 
    <textElement/> 
    <textFieldExpression><![CDATA["Column for " + $P{title2}]]></textFieldExpression> 
</textField> 
+0

@NikunjChauhanはちょうど私のポストを更新 –

+0

どうもありがとう!最初のクエリでは、答えを完成させるために、JRXMLのパラメータをのように宣言する必要があります。 – Nik

関連する問題