2017-04-24 29 views
0

の代わりに使用するためには何が6.3.0バージョンに4.8.0からJasperReportsのライブラリを更新します。JasperReportsの6.xでは:非推奨JRTextExporterParameter.LINE_SEPARATOR

しかし、輸出者にはsetLineSeparatorのようなメソッドはありません。 JRTextExporter.setParameter(JRTextExporterParameter.LINE_SEPARATOR)は推奨されていません。このような

設定は動作しません:jrxmlでプロパティとして

Exporter exporter = new JRTextExporter(); 
((JRTextExporter)exporter).getParameters().put(JRTextExporterParameter.LINE_SEPARATOR, "\r\n"); 
exporter.setExporterOutput(new SimpleWriterExporterOutput(outputFile, characterEncodingProp)); 

設定でも動作しません:

<property name="net.sf.jasperreports.export.text.line.separator" value="&#xD;&#xA;"/> 

または私はラインを設定することができますどのように

<property name="net.sf.jasperreports.export.text.line.separator" value="\r\n"/> 

セパレータ?代わりに、私たちはTextExporterConfiguration.getLineSeparatorメソッドを使用する必要があり、非推奨JRTextExporterParameter.LINE_SEPARATORプロパティを使用しての

答えて

1

SimpleTextExporterConfigurationコードは次のようになりますクラス(これは TextExporterConfigurationインタフェースの具体的な実装である)を使用した場合には

net.sf.jasperreports.export.text.character.widthnet.sf.jasperreports.export.text.character.height私たちの助けを借りて

JRExporter exporter = new JRTextExporter(); 

SimpleTextExporterConfiguration configuration = new SimpleTextExporterConfiguration(); 
configuration.setLineSeparator("#"); 

exporter.setConfiguration(configuration); 

exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); 
exporterOutput = new SimpleWriterExporterOutput(file); 
exporter.setExporterOutput(exporterOutput); 
exporter.exportReport(); 

を文字の幅と高さを設定できます。

jrxmlヘッダの抜粋:

<?xml version="1.0" encoding="UTF-8"?> 
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" ..> 
    <property name="net.sf.jasperreports.export.text.character.width" value="7.2"/> 
    <property name="net.sf.jasperreports.export.text.character.height" value="14.0"/> 
+0

私はSimpleTextReportConfigurationを使用しました。 私はまたこのようなメソッドが必要です configuration.setCharWidth(10f); configuration.setCharHeight(20f); SimpleTextExporterConfigurationにはこれらのメソッドはありません。 – OGSL

+0

これは別の質問ですが、私は自分の投稿に情報を追加しました:) –

0

感謝の。このようなコードもタスクを解決しました:

Exporter exporter = new JRTextExporter(); 
final SimpleTextReportConfiguration txtConfiguration = new SimpleTextReportConfiguration(); 
txtConfiguration.setCharWidth(10f); 
txtConfiguration.setCharHeight(20f); 
exporter.setConfiguration(txtConfiguration); 
SimpleTextExporterConfiguration configuration = new SimpleTextExporterConfiguration(); 
configuration.setLineSeparator("\r\n"); 
exporter.setConfiguration(configuration);