/** * 功能:获取部门盘点设备明细Excel文件 * * @return File * @throws DataTransException */ public File getExportFile() throws DataTransException { File file = null; try { CostCheckResultModel modelProducer = (CostCheckResultModel) sqlProducer; SQLModel sqlModel = modelProducer.getPageQueryModel(); String reportTitle = "盘点结果报表(按部门)"; String fileName = reportTitle + ".xls"; String filePath = WorldConstant.USER_HOME; filePath += WorldConstant.FILE_SEPARATOR; filePath += fileName; TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setSourceConn(conn); rule.setTarFile(filePath); DataRange range = new DataRange(); rule.setDataRange(range); rule.setFieldMap(getFieldMap()); CustomTransData custData = new CustomTransData(); custData.setReportTitle(reportTitle); custData.setReportPerson(userAccount.getUsername()); custData.setNeedReportDate(true); rule.setCustData(custData); rule.setCalPattern(LINE_PATTERN); TransferFactory factory = new TransferFactory(); DataTransfer transfer = factory.getTransfer(rule); transfer.transData(); file = (File) transfer.getTransResult(); } catch (SQLModelException ex) { ex.printLog(); throw new DataTransException(ex); } return file; }
public File exportFile() throws DataTransException { File file = null; try { SQLModel sqlModel = sqlProducer.getPageQueryModel(); TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setSourceConn(conn); String fileName = "备件业务单据统计表.xls"; String filePath = WorldConstant.USER_HOME; filePath += WorldConstant.FILE_SEPARATOR; filePath += fileName; rule.setTarFile(filePath); DataRange range = new DataRange(); rule.setDataRange(range); Map fieldMap = new HashMap(); fieldMap.put("TRANS_NO", "单据号"); fieldMap.put("CREATED_USER", "创建人"); fieldMap.put("CREATION_DATE", "创建日期"); fieldMap.put("TRANS_STATUS_NAME", "单据状态"); fieldMap.put("TRANS_TYPE_NAME", "单据类型"); rule.setFieldMap(fieldMap); CustomTransData custData = new CustomTransData(); custData.setReportTitle(fileName); custData.setReportPerson(sfUser.getUsername()); custData.setNeedReportDate(true); rule.setCustData(custData); /*rule.setSheetSize(1000);*/ // 设置分页显示 TransferFactory factory = new TransferFactory(); DataTransfer transfer = factory.getTransfer(rule); transfer.transData(); file = (File) transfer.getTransResult(); } catch (SQLModelException ex) { ex.printLog(); throw new DataTransException(ex); } return file; }