手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

报表控件FineReport中如何自定义上传文件至磁盘

时间:2024-10-12 04:48:39

1、编写类文件定义一个OutputExcel类文件,实现AbstractOutputFileAction接口,具体代码如下:package c泠贾高框om.fr.output;import java.io.*;import com.fr.json.JSONException;import com.fr.json.JSONObject;import com.fr.schedule.output.AbstractOutputFileAction;import com.fr.schedule.output.OutputFileAction;public class OutputExcel extends AbstractOutputFileAction{@Overridepublic File[] getFilesToDealWith(File[] files) {return files;}@Overridepublic void doFileAction(File[] files) {// OutputStream out=new BufferedOutputStream(new FileOutputStream(new File(files.)));;System.out.println(files[0].getName());for(int i=0;i<files.length;i++){String name=files[i].getName();String path="D:/"+name;BufferedInputStream in=null;OutputStream out=null;try {out=new BufferedOutputStream(new FileOutputStream(new File(path)));in=new BufferedInputStream(new FileInputStream(files[i]));byte[] ba=new byte[in.available()];in.read(ba);out.write(ba);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}finally{try {if(in!=null){in.close();}if(out!=null){out.close();}} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}}@Overridepublic boolean isEmailNotification() {// TODO Auto-generated method stubreturn false;}@Overridepublic OutputFileAction analyzeJSON(JSONObject arg0) {// TODO Auto-generated method stubreturn null;}@Overridepublic JSONObject createJSONConfig() throws JSONException {// TODO Auto-generated method stubreturn null;}@Overridepublic String getJsonTag() {// TODO Auto-generated method stubreturn null;}}编译类文件,将生成的OutputExcel.class放在%FineReport_home%\WebReport\WEB-INF\classes\com\fr\output文件夹下。注:类文件放的位置只需要与编写类文件里面的package位置对应即可。

2、定时任务在附件类型后面勾选excel,word,pdf,则可将定时任务结果导出为excel,word以及pdf格式,然后勾选下面的是否自定义附件处理,并在类名处填写正确类名,点击完成即可。如下图:

报表控件FineReport中如何自定义上传文件至磁盘

3、效果查看在D盘下面可以查看到3个不同格式的导出文件,分别为aaaa.xls;aaaa.pdf;aaaa.doc。如下图:

报表控件FineReport中如何自定义上传文件至磁盘
© 手抄报圈