2

我从我的 NetBeans GUI 创建了一个报告,它工作正常,但突然间编译器现在显示错误。

package dreportsample;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import net.sf.dynamicreports.examples.Templates;
import net.sf.dynamicreports.report.builder.style.StyleBuilder;
import net.sf.dynamicreports.report.constant.HorizontalAlignment;
import net.sf.dynamicreports.report.datasource.DRDataSource;
import net.sf.dynamicreports.report.exception.DRException;
import net.sf.jasperreports.engine.JRDataSource;

/**
 * @author Ricardo Mariaca (dynamicreports@gmail.com)
 */
public class DReportSample {

    public DReportSample() {
        build();
    }

    private void build() {  
            StyleBuilder boldStyle         = stl.style().bold();
            StyleBuilder boldCenteredStyle = stl.style(boldStyle).setHorizontalAlignment
                    (HorizontalAlignment.CENTER).setFontSize(15);
            StyleBuilder footerLeft         = stl.style().setHorizontalAlignment
                   (HorizontalAlignment.LEFT) ;
             StyleBuilder footerRight         = stl.style().setHorizontalAlignment
                   (HorizontalAlignment.RIGHT) ;
            //BufferedImage img = new BufferedImage(1200,1200,BufferedImage.TYPE_INT_RGB);
           BufferedImage img = null;
try {
   // img = ImageIO.read(new File("D:/Hysteresis.png"));
    img = ImageIO.read(new File("D:/Hysteresis.png"));
} catch (IOException e) {
}
       BufferedImage logo = null;
try {
   // img = ImageIO.read(new File("D:/Hysteresis.png"));
    logo = ImageIO.read(new File("D:/Logo.jpg"));
} catch (IOException e) {
}
        try {
            report()//create new report design
                         // .setColumnTitleStyle(boldStyle)
                         // .setColumnStyle(boldStyle)
                          .highlightDetailEvenRows()
              .columns(//add columns

                col.column(null,"Col_1",      type.stringType()),
                col.column(null,"Col_2",  type.stringType())
                                )
                           .summary(
        cmp.verticalList()
            .add(cmp.text("\n\nHYSTERISIS PLOT").setStyle(boldStyle))
            .add(cmp.text("A brief description of what this plot signifies "
                                + "which means that change in are related to"
                                + " pain relief and subsequently"
                                + "should be encouraged \n\n\n\n"))
           // .add(cmp.image(getClass().getResourceAsStream
             //     ("D:/Hysteresis.png")).setFixedDimension(300, 300))


            .add(cmp.image(img).setFixedDimension(400, 300))
            .add(cmp.text("ANALYSIS\n\n\n").setStyle(boldStyle))
            .add(cmp.text("REMARKS\n\n\n\n").setStyle(boldStyle))
            .add(cmp.text("Doctor Signature").setStyle(boldStyle))
    )
              .title(

                                cmp.horizontalList()
                                .add(
                                cmp.image(logo).setFixedDimension(70, 70),
                                cmp.verticalList()
                                .add(
                                cmp.text("Address Line 1").setStyle(boldCenteredStyle),
                                cmp.text("Address Line 2").setStyle(boldCenteredStyle),
                                cmp.text("Address Line 3").setStyle(boldCenteredStyle))
                                )

                                .newRow()
 .add(cmp.filler().setStyle(stl.style().setTopBorder(stl.pen2Point())).setFixedHeight(10))

                                )//shows report title

                              //  .pageFooter(cmp.pageXofY())//shows number of page at page footer
                                .pageFooter(
                                Templates.footerComponent,
                                 //cmp.text("Emsol Software Solution \t\t\t\t\t\t\t\t"
                               // + " copyright: gauravbvelelx@gmail.com")
                                cmp.horizontalList()
                                .add(cmp.text("Emsol Software Solution").setStyle(footerLeft),
                                cmp.text("copyright: gauravbvelex@gmail.com").setStyle(footerRight))
                                )

              .setDataSource(createDataSource())//set datasource
              .show();//create and show report
        } catch (DRException e) {
            e.printStackTrace();
        }
    }
    private JRDataSource createDataSource() {
        DRDataSource dataSource = new DRDataSource("Col_1", "Col_2");

        dataSource.add("Name","Sample");
                dataSource.add("Age","26");
                dataSource.add("Sex","Female");
                dataSource.add("Weight","53 Kg");
                dataSource.add("BMI","20");
                dataSource.add("Massage Duration (Mins)","4.5");
                dataSource.add("RPM","26");
                dataSource.add("Doctor Attended","Doctor");
                dataSource.add("Date","22-Feb-2013");

        return dataSource;
    }   


    public static void main(String[] args) {
        new DReportSample();
    }
}

这段代码在几个小时前运行良好。但现在它突然显示错误:附加屏幕截图

在此处输入图像描述

它在 report() 和其他部分也显示了同样的错误。基本上它无法识别动态报告库的各种类和字段,尽管该库已成功导入,但几个小时前它运行良好。

我使用动态报告的方式是添加如下库:

1) Downloaded dynamicreports-3.1.0-project-with-dependencies
2) Unzipped
3) In my Netbeans Project
Libraries -> Add Jar/folder -> Selecting all files from dynamicreports-3.1.0-project-with-dependencies\dynamicreports-3.1.0\lib
Libraries -> Add Jar/folder -> Selecting all files from dynamicreports-3.1.0-project-with-dependencies\dynamicreports-3.1.0\dist

在此处输入图像描述

它工作正常,但后来我更改了保存 dynamicreports-3.1.0-project-with-dependencies 的文件夹的名称,因此它给了我添加库的参考错误。所以我再次将其更改为以前的名称,但从那以后我得到了显示的错误。

我已经尝试了一切,构建新项目并按照提到的步骤或重新下载新的 dynamicreports-3.1.0-project-with-dependencies 并再次按照步骤操作。但似乎没有任何效果,因为我离完成我的项目如此接近,这令人沮丧。

任何人都可以帮忙吗?

谢谢

4

1 回答 1

0

好的。。解决了。。

下面的行被删除导致错误:

导入静态 net.sf.dynamicreports.report.builder.DynamicReports.*;

于 2013-02-24T12:23:09.163 回答