FineReport6.5 Java报表软件离线填写报表离线填报示例
本例以一个实例来展现FineReport  Java报表软件离线填写报表功能。
下图为一个雇员统计表: FineReport6.5  Java报表软件设计器里的报表设计如下图:
 
FineReport6.5 Java报表软件模板中报表填报属性如下:
 
保存该模板到C:\FineReport6.2\WebReport\WEB-INF\reportlets目录下,命名为WorkBook1.cpt。
依次点击FineReport文件输出Excel格式原样导出,得下图的.xls文件:
 
填写雇员信息如下:
 
 将其另存,路径为C:\WorkSheet1.xls.。
运行如下导入程序即可将数据导入数据库中,注意此处要特别留心程序中几个路径是否正确。
import java.io.FileInputStream;
import java.util.HashMap;
  
import com.fr.base.FRContext;   
import com.fr.base.dav.LocalEnv;
import com.fr.report.ReportTemplate;
import com.fr.report.io.ExcelImporter;public class TestUtils {
public void exe() {
// 配置系统运行环境,可以localEnv remoteEnv
com.fr.base.dav.LocalEnv env = new LocalEnv("C:\\FineReport6.5\\WebReport\\WEB-INF");
try {
// 设置
FRContext.setCurrentEnv(env);
// 读取模板
ReportTemplate tpl = env.readTemplate("WorkBook1.cpt");
// 读取Excel文件
FileInputStream file = new FileInputStream("C:\\WorkSheet1.xls");
// 调用方法,具体如下
ExcelImporter.importExcel(tpl, new HashMap(), file);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
public static void main(String[] args)
{
TestUtils testUtils = new TestUtils();
testUtils.exe();
}
}
查看数据库中数据见下图:
 
 至此离线填报成功。