• <legend id='4KPdJ'><style id='4KPdJ'><dir id='4KPdJ'><q id='4KPdJ'></q></dir></style></legend><tfoot id='4KPdJ'></tfoot>
    <i id='4KPdJ'><tr id='4KPdJ'><dt id='4KPdJ'><q id='4KPdJ'><span id='4KPdJ'><b id='4KPdJ'><form id='4KPdJ'><ins id='4KPdJ'></ins><ul id='4KPdJ'></ul><sub id='4KPdJ'></sub></form><legend id='4KPdJ'></legend><bdo id='4KPdJ'><pre id='4KPdJ'><center id='4KPdJ'></center></pre></bdo></b><th id='4KPdJ'></th></span></q></dt></tr></i><div id='4KPdJ'><tfoot id='4KPdJ'></tfoot><dl id='4KPdJ'><fieldset id='4KPdJ'></fieldset></dl></div>
      <bdo id='4KPdJ'></bdo><ul id='4KPdJ'></ul>

    <small id='4KPdJ'></small><noframes id='4KPdJ'>

        如何使报表页面方向更改为“rtl"?

        How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)

        • <bdo id='cddCA'></bdo><ul id='cddCA'></ul>

        • <i id='cddCA'><tr id='cddCA'><dt id='cddCA'><q id='cddCA'><span id='cddCA'><b id='cddCA'><form id='cddCA'><ins id='cddCA'></ins><ul id='cddCA'></ul><sub id='cddCA'></sub></form><legend id='cddCA'></legend><bdo id='cddCA'><pre id='cddCA'><center id='cddCA'></center></pre></bdo></b><th id='cddCA'></th></span></q></dt></tr></i><div id='cddCA'><tfoot id='cddCA'></tfoot><dl id='cddCA'><fieldset id='cddCA'></fieldset></dl></div>

                <small id='cddCA'></small><noframes id='cddCA'>

                  <tbody id='cddCA'></tbody>
                <tfoot id='cddCA'></tfoot><legend id='cddCA'><style id='cddCA'><dir id='cddCA'><q id='cddCA'></q></dir></style></legend>

                  本文介绍了如何使报表页面方向更改为“rtl"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 JasperReports 创建一个报告,使用 iReport 生成的 jrxml 文件.

                  I am creating a report with JasperReports, using iReport generated jrxml file.

                  我的应用程序是多语言的(英语 (LTR) 和波斯语 (RTL)).在生成的表格中,关于文本的方向,我需要交换整个页面方向.另外,我使用 locale 功能.

                  My application is multilingual, (English (LTR) and Persian (RTL)). In tables generated, regarding to the direction of text I need to swap the whole page direction. Plus I use locale feature.

                  我google了很多,终于找到了一个属性JRXlsAbstractExporter.PROPERTY_SHEET_DIRECTION, "RTL",但是在excel生成的格式中设置这个属性对我的报告没有任何影响.

                  I googled a lot and finally found an attribute JRXlsAbstractExporter.PROPERTY_SHEET_DIRECTION, "RTL" but setting this attribute in excel generated formats don't have any impact on my report.

                      params.put(JRXlsAbstractExporter.PROPERTY_SHEET_DIRECTION, "RTL");
                      JasperPrint jasperPrint = JasperFillManager.fillReport(report,params, 
                             dataSource != null ? new JRMapArrayDataSource(dataSource) : new JREmptyDataSource());    
                  

                  我尝试的另一件事是在导出器参数中设置如下:

                  another thing I tried is setting this in exporter parameters as following:

                      JRExporter exporter = new JRXlsxExporter();
                      exporter.setParameter(JRXlsAbstractExporter.PROPERTY_SHEET_DIRECTION, "RTL");
                      exporter.exportReport();
                  

                  但不允许设置此参数,我得到错误.
                  如果您对如何更改报告页面方向(或者换句话说,在特定区域设置整个报告)进行更改有任何经验,请提供帮助.

                  but setting this parameter is not allowed and I get error.
                  If you have any experience for how to make a report page direction (or in other words mirror the whole report in specific locale) to change please help.

                  推荐答案

                  据我搜索没有属性,可以使用下面的util类:

                  As far as I searched there is no property, you can use below util class:

                  package foo.bar.utils.export;
                  
                  import java.util.Iterator;
                  import java.util.List;
                  
                  import net.sf.jasperreports.engine.JRPrintElement;
                  import net.sf.jasperreports.engine.JRPrintFrame;
                  import net.sf.jasperreports.engine.JRPrintPage;
                  import net.sf.jasperreports.engine.JasperPrint;
                  
                  /**
                   * Report utilities
                   * Please refer to: http://community.jaspersoft.com/questions/523041/right-left-arabic-reports
                   * There is another solution at: http://jaspermirror.sourceforge.net/
                   * which is not used here
                   * @author AFattahi
                   *
                   */
                  public class ReportUtils {
                  
                      private ReportUtils(){
                  
                      }
                      /**
                       * mirror each page layout
                       * @param print
                       */
                      public static void mirrorLayout(JasperPrint print) {
                          int pageWidth = print.getPageWidth();
                          for (Object element : print.getPages()) {
                              JRPrintPage page = (JRPrintPage) element;
                              mirrorLayout(page.getElements(), pageWidth);
                          }
                      }
                  
                      /**
                       * mirror a list of elements
                       * @param print
                       */
                      protected static void mirrorLayout(List<?> elements, int totalWidth) {
                          for (Iterator<?> it = elements.iterator(); it.hasNext();) {
                              JRPrintElement element = (JRPrintElement) it.next();
                              int mirrorX = totalWidth - element.getX() - element.getWidth();
                              element.setX(mirrorX);
                  
                              if (element instanceof JRPrintFrame) {
                                  JRPrintFrame frame = (JRPrintFrame) element;
                                  mirrorLayout(frame.getElements(), frame.getWidth());
                              }
                          }
                      }
                  }
                  

                  请考虑 JRXlsxExporter 不支持 RTL(似乎是版本 6 中的错误),您必须 JRXlsExporter

                  Please consider that the JRXlsxExporter does not support RTL (seems to be a bug in version 6) and you must JRXlsExporter

                  exporter = new JRXlsExporter();
                  exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(out));
                  SimpleXlsReportConfiguration xlsReportConfig = new SimpleXlsReportConfiguration();
                  xlsReportConfig.setSheetDirection(RunDirectionEnum.RTL);
                  exporter.setConfiguration(xlsReportConfig);
                  

                  这篇关于如何使报表页面方向更改为“rtl"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                  How to find out locale-dependent text orientation in java?(如何在java中找出依赖于语言环境的文本方向?)

                    <tfoot id='JSufP'></tfoot>
                      • <bdo id='JSufP'></bdo><ul id='JSufP'></ul>
                            <i id='JSufP'><tr id='JSufP'><dt id='JSufP'><q id='JSufP'><span id='JSufP'><b id='JSufP'><form id='JSufP'><ins id='JSufP'></ins><ul id='JSufP'></ul><sub id='JSufP'></sub></form><legend id='JSufP'></legend><bdo id='JSufP'><pre id='JSufP'><center id='JSufP'></center></pre></bdo></b><th id='JSufP'></th></span></q></dt></tr></i><div id='JSufP'><tfoot id='JSufP'></tfoot><dl id='JSufP'><fieldset id='JSufP'></fieldset></dl></div>
                            <legend id='JSufP'><style id='JSufP'><dir id='JSufP'><q id='JSufP'></q></dir></style></legend>
                              <tbody id='JSufP'></tbody>

                            <small id='JSufP'></small><noframes id='JSufP'>