jasperreport生成简单的报表

1、建立jrxml文件。

.jrxml是XML文件类型。可以用Ireport自动生成。也可以自己写一个。

2、对 .jrxml文件转成.jasper文件。

JasperCompileManager.compileReportToFile("d:/reports/"+fileName+".jrxml");

3、把.jasper文件转成PDF文件

JasperRunManager.runReportToPdfFile("d:/reports/"+fileName+".jasper","d:/reports/"+fileName+".pdf",new HashMap(), new JREmptyDataSource());

这只是一个简单的报表,想要更复杂的还可以在里面加入元素。

这样完成任务:)

程序:

import java.util.HashMap;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperRunManager;

public class Pdf
{

 public static void main(String []arg)
 {
     try
     {
      String fileName="FirstReport";
      System.out.println("Starting..."); 
      JasperCompileManager.compileReportToFile("d:/reports/"+fileName+".jrxml");
      JasperRunManager.runReportToPdfFile("d:/reports/"+fileName+".jasper","d:/reports/"+fileName+".pdf",new HashMap(), new JREmptyDataSource());
      System.out.println("Done...");
     }
     catch (JRException e)
     {
       e.printStackTrace();
     }
 }
}

 

jrxml:

<?xml version="1.0"?>
<!DOCTYPE jasperReport
  PUBLIC "-//JasperReports//DTD Report Design//EN"
  "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="FirstReport">
 <detail>
   <band height="500"  isSplitAllowed="true" >
    <staticText>
     <reportElement
      x="84"
      y="0"
      width="382"
      height="91"
      key="staticText-1"/>
     <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
     <textElement>
      <font size="20"/>
     </textElement>
    <text><![CDATA[Welcome to here!]]></text>
    </staticText>
        <staticText>
     <reportElement
      x="84"
      y="50"
      width="382"
      height="91"
      key="staticText-1"/>
     <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
     <textElement>
      <font size="20"/>
     </textElement>
    <text><![CDATA[Welcome to here!]]></text>
    </staticText>
        <staticText>
     <reportElement
      x="284"
      y="0"
      width="382"
      height="91"
      key="staticText-1"/>
     <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
     <textElement>
      <font size="20"/>
     </textElement>
    <text><![CDATA[Welcome to here!]]></text>
    </staticText>
        <staticText>
     <reportElement
      x="284"
      y="50"
      width="382"
      height="91"
      key="staticText-1"/>
     <box topBorder="None" topBorderColor="#FFFFFF" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
     <textElement>
      <font size="20"/>
     </textElement>
    <text><![CDATA[Welcome to here!]]></text>
    </staticText>
        <staticText>
     <reportElement
      x="284"
      y="200"
      width="382"
      height="91"
      key="staticText-1"/>
     <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
     <textElement>
      <font size="20"/>
     </textElement>
    <text><![CDATA[Welcome to here!]]></text>
    </staticText>
        <staticText>
     <reportElement
      x="284"
      y="250"
      width="382"
      height="91"
      key="staticText-1"/>
     <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
     <textElement>
      <font size="20"/>
     </textElement>
    <text><![CDATA[Welcome to here!]]></text>
    </staticText> 
   </band>
  </detail>
</jasperReport>

 

over!:)

 

该数据集包含50万份为教育数据挖掘和学习分析领域研究和建模目的生成的合成学生学期记录。该数据集旨在反映真实、多维度的学生行为,同时嵌入特定的统计属性,使其适合进行超越简单线性基线的回归和分类基准测试。数据涵盖学生人口统计、社会经济背景、学业经历、行为与生活方式模式、心理指标,以及两个学业表现目标:期中成绩和期末考试成绩。标识符柱状结构类型范围 / 数值描述Student_ID整数1 — 500,000每个学生记录的唯一标识符Semester_ID整数1 — 8学期编号(1 = 第一学期)人口统计柱状结构类型范围 / 数值描述Age整数17 — 30学生年龄(按年龄计算)Gender范畴男性,女性,非二元性别自我报告的性别Region_Type范畴城市、农村无论学生的家乡是城市还是农村Family_Size整数2 — 8学生家庭总人数高基数范畴特征柱状结构类型独特价值描述Major_Subject范畴18学术专业/学科领域University_Name范畴25学生就读的大学名称Home_City范畴40学生永久居住城市社会经济特征柱状结构类型范围 / 数值描述Parent_Education范畴无教育背景,小学、中学、文凭、学士、研究生学生家长完成的最高教育水平Family_Income_Level范畴低中、中下、中、上中、高家庭收入的序数分类Internet_Quality漂浮1.0 — 10.0自报的网络连接质量。城市学生的平均得分略高Study_Space_Quality漂浮1.0 — 10.0学生在家中专注学习环境的质量学术历史柱状结构类型范围 / 数值描述Previous_GPA漂浮0.00 — 4.00前几个学期的累计GPANumber_of_Failed_Courses整数0 — 10之前挂科的课程总数。遵循右偏分布Total_Credits_Earned整数情况各异累计学分,按学期编号计算行为与生活方式特征柱状结构类型范围 / 数值描述Weekly_Study_Hours漂浮2.0 — 40.0每周平均学习小时数Attendance_Rate漂浮0.0 — 100.0参加课程的比例。偏左;大多数学生定期就读Library_Visits_Per_Month整数0 — 25学生每月访问图书馆的次数。高度相关 (r r ≈ 0.75)Weekly_Study_HoursExtracurricular_Hours漂浮0.0 — 30.0每周课外活动时间。右倾Sleep_Hours漂浮3.0 — 11.0平均每晚睡眠小时数Social_Media_Usage_Hours漂浮0.0 — 12.0每天在社交媒体平台上花费的时间心理特征柱状结构类型范围 / 数值描述Stress_Level漂浮1.0 — 10.0感知压力水平。与考试成绩呈非线性(倒U)关系Motivation_Score漂浮1.0 — 10.0自我报告的学术动机Self_Efficacy_Score漂浮1.0 — 10.0对自己成功能力的信心。基于GPA和动力,再加上噪音目标变量柱状结构类型范围 / 数值描述Midterm_Mark漂浮0.0 — 100.0期中考试成绩Final_Exam_Score漂浮0.0 — 100.0期末考试成绩。主要建模目标
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值