润乾报表中常用的测试环境JSP(上)



在报表的部署以及使用中,经常会遇到一些数据源或者环境配置方面的问题,本文提供了两个测试常用的JSP,可以在出现相关问题时用来进行测试。

data_source_test.jsp–测试数据源,可以检测数据源是否被正确配置,以及是否可以连接。

<%@ page contentType=”text/html;charset=GBK” %>
<%@ page import=”com.runqian.report4.usermodel.*”%>
<%@ page import=”com.runqian.base4.util.*”%>
<%@ page import=”com.runqian.report4.model.*”%>
<%@ page import=”com.runqian.report4.util.*”%>
<%@ page import=”com.runqian.report4.cache.CacheManager”%>
<%@ page import=”java.io.*”%>

<%@ page import=”com.runqian.report4.dataset.DataSet”%>
<%@ page import=”com.runqian.report4.dataset.SQLDataSetFactory”%>
<%@ page import=”com.runqian.report4.view.olap.OlapUtils”%>
<%@ page import=”com.runqian.report4.view.excel.ExcelReport”%>
<%@ page import=”java.sql.Connection”%>
<%@ page import=”java.sql.Driver”%>
<%@ page import=”java.sql.DriverManager”%>
<%@page import=”com.runqian.report4.ide.ExcelImporter”%>
<%@page import=”com.runqian.report4.usermodel.input.InputProperty”%>
<%@page import=”com.runqian.report4.input.DataSaver”%>
<%@page import=”com.runqian.report4.model.engine.ExtCellSet”%>
<%@page import=”com.runqian.report4.model.engine2.RowReport”%>
<%@page import=”com.runqian.report4.input.RowReportSaver”%>
<%@page import=”java.text.SimpleDateFormat”%>
<%@page import=”com.runqian.base4.resources.FormatUtils”%>
<%@page import=”java.util.Locale”%>



<%
//设置报表路径
String reportFile = “D:\\testupdate.raq”;
Context cxt = new Context();
ReportDefine rd = null;
try {
rd = (ReportDefine) ReportUtils.read(reportFile);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(”报表读取完毕===================================”);
//计算报表
Engine engine = new Engine(rd, cxt);
IReport iReport = engine.calc();
RowReport rr = (RowReport)iReport;
String did = rr.getDetailID( 1 ); //第几行是主扩展行
SimpleDateFormat dateF = new SimpleDateFormat( FormatUtils.getDateFormat( Locale.getDefault() ) );
SimpleDateFormat timeF = new SimpleDateFormat( FormatUtils.getTimeFormat( Locale.getDefault() ) );
SimpleDateFormat datetimeF = new SimpleDateFormat( FormatUtils.getDatetimeFormat( Locale.getDefault() ) );
System.out.println(”报表计算完毕@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@”);
String excelFile = “D:\\test1500.xls”;
ExcelImporter ei = new ExcelImporter(excelFile);
IReport excelReport = ei.getReport(0);
RowReportSaver rowSaver = new RowReportSaver(rr, null, cxt); //构造数据保存对象
System.out.println(” 获取Excel完毕&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&”);
//读入excel文件及其数据
for(int i=1;i<=excelReport.getRowCount();i++){ 逐行逐列把excel数据写入填报表
Area area = rr.insertDetail( did );
//for(int j=1;j<=iReport.getColCount();j++){
//INormalCell iExcelCell=excelReport.getCell(i, (short)j); //取得excel单元格

//if( iExcelCell == null ) continue;
//String svalue = “”;
//Object value = iExcelCell.getValue();
//if( value != null ) svalue = value.toString();


//if((short)j==1 && svalue.length()>3){
//list.add((”第”+sheetNum+”页的第”+i+”行”+”第”+(short)j+”列的值”+svalue+”字符长度大于3!”));
//throw new Exception(”校验失败”);
//}

//}
for(int j=1;j<=iReport.getColCount();j++){
INormalCell iExcelCell=excelReport.getCell(i, (short)j); //取得excel单元格

if( iExcelCell == null ) continue;
String svalue = “”;
Object value = iExcelCell.getValue();
if( value != null ) svalue = value.toString();

rowSaver.setCellInputValue( area.getBeginRow(), (short)j, svalue, dateF, timeF, datetimeF );

}

}

System.out.println(”设置更新属性完毕%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%”);

rowSaver.save(); //执行保存
out.print(”数据保存成功”);

%>


enum_font.jsp–列出java环境的字体,当发现统计图里面的字体不正确时,可通过这个jsp检测系统中是否有统计图中使用的字体。

<%@ page language=”java” pageEncoding=”GBK”%>

<%
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontNames= ge.getAvailableFontFamilyNames();
%>




当前Java环境支持的字体列表


<%
for(int i=0;i <fontnames.length;i++)
out.println(”
  • ”+fontNames[i]);
    %>
    • 0
      点赞
    • 0
      收藏
      觉得还不错? 一键收藏
    • 0
      评论
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

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

    抵扣说明:

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

    余额充值