亚洲AV日韩AⅤ综合手机在线观看,激情婷婷久久综合色,欧美色五月婷婷久久,久久国产精品99久久人人澡

  • <abbr id="uk6uq"><abbr id="uk6uq"></abbr></abbr>
  • <tbody id="uk6uq"></tbody>
  • 怎么用JFreeReport做報(bào)表實(shí)踐

    時(shí)間:2024-08-19 05:57:00 JAVA認(rèn)證 我要投稿
    • 相關(guān)推薦

    怎么用JFreeReport做報(bào)表實(shí)踐

      準(zhǔn)備工作:

      下載jfreeReport0.8.7 地址:http://www.jfree.org/jfreereport/index.php

      Java認(rèn)證:用JFreeReport做報(bào)表實(shí)踐,使用JFreeReport生成報(bào)表通常需要以下三個(gè)基本步驟:

      A.生成可通過(guò)TableModel接口訪問(wèn)的數(shù)據(jù),如本例中的createData方法完成的功能。

      B.生成一個(gè)JFreeReport實(shí)例,他定義了我們?nèi)绾胃袷交@示數(shù)據(jù),如本例中的createReportDefinition方法完成的功能。

      C.將數(shù)據(jù)和JFreeReport實(shí)例連接起來(lái),并且將該JFreeReport實(shí)例傳給PreviewDialog的一個(gè)實(shí)例顯示給用戶。

      下面開(kāi)始:

      1.新建一個(gè)WEB工程,在WebRoot\lib中import 如下jar文件:jcommon-1.0.1.jar jfreereport-0.8.7.jar jfreereport-demo-0.8.7.jar jfreereport-servlet-demo-0.8.7.jar

      (可在jfreereport包中解壓得到)

      2.寫一個(gè)Demo.java 加入到工程的src包中。 內(nèi)容如下:

      import java.awt.Color;

      import java.awt.geom.Point2D;

      import javax.swing.table.DefaultTableModel;

      import javax.swing.table.TableModel;

      import org.jfree.report.ElementAlignment;

      import org.jfree.report.JFreeReport;

      import org.jfree.report.JFreeReportBoot;

      import org.jfree.report.ReportProcessingException;

      import org.jfree.report.demo.helper.DefaultCloseHandler;

      import org.jfree.report.demo.helper.DemoHandler;

      import org.jfree.report.demo.helper.PreviewHandler;

      import org.jfree.report.elementfactory.TextFieldElementFactory;

      import org.jfree.report.modules.gui.base.PreviewDialog;

      import org.jfree.ui.FloatDimension;

      import org.jfree.util.Log;

      public class Demo implements DemoHandler

      {

      private class HelloWorldPreviewHandler implements PreviewHandler

      {

      public HelloWorldPreviewHandler()

      {

      }

      public void attemptPreview()

      {

      executeReport();

      }

      }

      public Demo (){

      }

      protected void executeReport ()

      {

      final TableModel data = createData();

      final JFreeReport report = createReportDefinition();

      report.setData(data);

      try

      {

      final PreviewDialog preview = new PreviewDialog(report);

      preview.addWindowListener(new DefaultCloseHandler());

      preview.pack();

      preview.setVisible(true);

      }

      catch (ReportProcessingException e)

      {

      Log.error(“Failed to generate report ”, e);

      }

      }

      private TableModel createData ()

      {

      final Object[] columnNames = new String[]{“Column1”, “Column2”};

      final DefaultTableModel result = new DefaultTableModel(columnNames, 101);

      for (int i=1;i《101;i++){

      result.setValueAt(“用繁體字寫幾個(gè)看看\n”, i, 0);

      result.setValueAt(“簡(jiǎn)體中文輸出第”+i+“次”, i, 1);

      }

      return result;

      }

      private JFreeReport createReportDefinition ()

      {

      final JFreeReport report = new JFreeReport();

      report.setName(getDescription());

      TextFieldElementFactory factory = new TextFieldElementFactory();

      factory.setName(“T1”);

      factory.setAbsolutePosition(new Point2D.Float(0, 0));

      factory.setMinimumSize(new FloatDimension(150, 12));

      factory.setColor(Color.black);

      factory.setHorizontalAlignment(ElementAlignment.RIGHT);

      factory.setVerticalAlignment(ElementAlignment.MIDDLE);

      factory.setNullString(“-”);

      factory.setFieldname(“Column1”);

      report.getItemBand()。addElement(factory.createElement());

      factory = new TextFieldElementFactory();

      factory.setName(“T2”);

      factory.setAbsolutePosition(new Point2D.Float(200, 0));

      factory.setMinimumSize(new FloatDimension(150, 12));

      factory.setColor(Color.black);

      factory.setHorizontalAlignment(ElementAlignment.LEFT);

      factory.setVerticalAlignment(ElementAlignment.MIDDLE);

      factory.setNullString(“-”);

      factory.setFieldname(“Column2”);

      report.getItemBand()。addElement(factory.createElement());

      return report;

      }

      protected String getDescription ()

      {

      return “A Very Simple Report”;

      }

      public String getDemoName()

      {

      return “Hello World Demo (External)”;

      }

      public PreviewHandler getPreviewHandler()

      {

      return new HelloWorldPreviewHandler();

      }

      public static void main (final String[] args)

      {

      JFreeReportBoot.getInstance()。start();

      new Demo()。executeReport();

      }

      }

      3.在eclipse 中運(yùn)行(Shift+Alt+X J)運(yùn)行出來(lái)了。 仍有錯(cuò)誤或警告。下面來(lái)消除它們。

      4.Exception in thread “export-worker——1” java.lang.NoClassDefFoundError: org/jfree/fonts/registry/FontRecord === 解決辦法是 import libfonts-0.1.4.jar

      5.WARN: Unable to initialize the module misc-bsf

      org.jfree.base.modules.ModuleInitializeException: Unable to load the bean scripting framework manager class. This class is required to execute the BSFExpressions. === 解決辦法是 import bsf-2.3.0.jar

      6.WARN: Unable to initialize the module misc-beanshellorg.jfree.base.modules.ModuleInitializeException: Unable to load the bean shell interpreter class. This class is required to execute the BeanShellExpressions. === 解決辦法是 import bsh-1.3.0.jar

      7.WARN: Unable to load module classes for parser-simple:org/jfree/xml/parser/AbstractXmlReadHandler

      WARN:Unable to load module classes for parser-ext:org/jfree/xml/parser/AbstractXmlReadHandler

      === 解決辦法是 import jcommon-xml-1.0.1.jar

      8.最終出現(xiàn):

      INFO:Registering fonts for the iText library; using a cached font registry.

      INFO:Completed font registration.

      INFO:setReport(……): started pagination .……

      OK,一切順利完成。

      9.總之最后的WebRoot\lib中一共引入了

      bsf-2.3.0.jar bsh-1.3.0.jar itext-1.3.6.jar jcommon-1.0.1.jar jfreereport-0.8.7.jar jfreereport-demo-0.8.7.jar jfreereport-servlet-demo-0.8.7.jar

      libfonts-0.1.4.jar poi-3.0-alpha1-20050704.jar

      這些JAR文件。

    【怎么用JFreeReport做報(bào)表實(shí)踐】相關(guān)文章:

    hr工作報(bào)表怎么做03-08

    怎么做冰淇淋03-12

    眉筆怎么用03-29

    面膜怎么用02-27

    丹麥面包怎么做02-14

    香蕉奶昔怎么做03-13

    意大利面怎么做03-14

    酸奶蛋糕怎么做03-12

    夏日冷飲怎么做03-11