/** * 功能:导出Excel文件。 * * @return File * @throws com.sino.base.exception.DataTransException */ public File exportFile() throws DataTransException { File file = null; try { DataTransfer transfer = null; SQLModel sqlModel = sqlProducer.getPageQueryModel(); TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setCalPattern(CalendarConstant.LINE_PATTERN); 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("WORKORDER_OBJECT_CODE", "地点编号"); fieldMap.put("WORKORDER_OBJECT_NAME", "地点简称"); fieldMap.put("WORKORDER_OBJECT_LOCATION", "所在地点"); fieldMap.put("ORGANIZATION_ID", "组织ID"); fieldMap.put("COUNTY_NAME", "所在区县"); fieldMap.put("DISABLE_DATE", "失效日期"); fieldMap.put("CATEGORY_NAME", "地点类别"); // fieldMap.put("IS_TEMP_ADDR", "是否临时地点"); fieldMap.put("CREATION_DATE", "创建日期"); fieldMap.put("CREATED_BY", "创建人"); fieldMap.put("PROJECT_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(); 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; }
public File exportFile() throws DataTransException { File file = null; try { ItemInfoDTO itemInfoDto = (ItemInfoDTO) dtoParameter; if (itemInfoDto.getQryType().equals(WebAttrConstant.BY_DAIWEI)) { SQLModel sqlModel = sqlProducer.getPageQueryModel(); TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setCalPattern(CalendarConstant.LINE_PATTERN); 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("ORG_NAME", "公司"); fieldMap.put("BARCODE", "条码"); fieldMap.put("ITEM_NAME", "设备名称"); fieldMap.put("ITEM_SPEC", "规格型号"); fieldMap.put("WORKORDER_OBJECT_CODE", "地点编号"); fieldMap.put("WORKORDER_OBJECT_LOCATION", "所在地点"); fieldMap.put("NAME", "代维公司"); rule.setFieldMap(fieldMap); CustomTransData custData = new CustomTransData(); custData.setReportTitle("设备信息"); custData.setReportPerson(sfUser.getUsername()); custData.setNeedReportDate(true); rule.setCustData(custData); TransferFactory factory = new TransferFactory(); DataTransfer transfer = factory.getTransfer(rule); transfer.transData(); file = (File) transfer.getTransResult(); } else { SQLModel sqlModel = sqlProducer.getPageQueryModel(); TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setCalPattern(CalendarConstant.LINE_PATTERN); 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("ORG_NAME", "公司"); fieldMap.put("BARCODE", "条码"); fieldMap.put("ITEM_NAME", "设备名称"); fieldMap.put("ITEM_SPEC", "规格型号"); fieldMap.put("ITEM_CATEGORY", "设备分类"); fieldMap.put("START_DATE", "启用日期"); fieldMap.put("PROJECT_NAME", "所属工程"); fieldMap.put("WORKORDER_OBJECT_NAME", "所属地点"); fieldMap.put("COUNTY_NAME", "所属区县"); rule.setFieldMap(fieldMap); CustomTransData custData = new CustomTransData(); custData.setReportTitle("设备信息"); custData.setReportPerson(sfUser.getUsername()); custData.setNeedReportDate(true); rule.setCustData(custData); 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; }