Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/importbasedata/basedataDemo.xls =================================================================== diff -u -r34951 -r36097 Binary files differ Index: ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/importbasedata/service/ExportBasedataManager.java =================================================================== diff -u -r33772 -r36097 --- ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/importbasedata/service/ExportBasedataManager.java (.../ExportBasedataManager.java) (revision 33772) +++ ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/importbasedata/service/ExportBasedataManager.java (.../ExportBasedataManager.java) (revision 36097) @@ -15,6 +15,12 @@ public interface ExportBasedataManager { public void exportBasedata(OutputStream os); + + /** + * 导出示例文件 + */ + public void exportBasedataDemo(OutputStream os); + /* * 获取导出xls的数据 */ Index: forgon-tools/src/main/java/com/forgon/tools/excel/ExcelHelper.java =================================================================== diff -u -r28013 -r36097 --- forgon-tools/src/main/java/com/forgon/tools/excel/ExcelHelper.java (.../ExcelHelper.java) (revision 28013) +++ forgon-tools/src/main/java/com/forgon/tools/excel/ExcelHelper.java (.../ExcelHelper.java) (revision 36097) @@ -173,7 +173,56 @@ cell.setCellStyle(cellHSSFCellStyle); return cell; } + + /** + * 删除列 + * @param sheet + * @param columnToDelete + */ + public static void deleteColumn(HSSFSheet sheet, int columnToDelete) { + for (int rId = 0; rId <= sheet.getLastRowNum(); rId++) { + HSSFRow row = sheet.getRow(rId); + for (int cID = columnToDelete; cID <= row.getLastCellNum(); cID++) { + HSSFCell cOld = row.getCell(cID); + if (cOld != null) { + row.removeCell(cOld); + } + HSSFCell cNext = row.getCell(cID + 1); + if (cNext != null) { + HSSFCell cNew = row.createCell(cID, cNext.getCellType()); + cloneCell(cNew, cNext); + //Set the column width only on the first row. + //Other wise the second row will overwrite the original column width set previously. + if (rId == 0) { + sheet.setColumnWidth(cID, sheet.getColumnWidth(cID + 1)); + } + } + } + } + } + + /** + * 右边列左移 + * @param cNew + * @param cOld + */ + private static void cloneCell(HSSFCell cNew, HSSFCell cOld) { + cNew.setCellComment(cOld.getCellComment()); + cNew.setCellStyle(cOld.getCellStyle()); + if (HSSFCell.CELL_TYPE_BOOLEAN == cNew.getCellType()) { + cNew.setCellValue(cOld.getBooleanCellValue()); + } else if (HSSFCell.CELL_TYPE_NUMERIC == cNew.getCellType()) { + cNew.setCellValue(cOld.getNumericCellValue()); + } else if (HSSFCell.CELL_TYPE_STRING == cNew.getCellType()) { + cNew.setCellValue(cOld.getStringCellValue()); + } else if (HSSFCell.CELL_TYPE_ERROR == cNew.getCellType()) { + cNew.setCellValue(cOld.getErrorCellValue()); + } else if (HSSFCell.CELL_TYPE_FORMULA == cNew.getCellType()) { + cNew.setCellValue(cOld.getCellFormula()); + } + } + @SuppressWarnings("deprecation") public static HSSFCell createCell(HSSFRow row, int cellNumer, String value, HSSFCellStyle cellHSSFCellStyle) { Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/importbasedata/exportBasedataDemo.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/importbasedata/exportBasedataDemo.jsp (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/importbasedata/exportBasedataDemo.jsp (revision 36097) @@ -0,0 +1,15 @@ + +<%@page import="com.forgon.disinfectsystem.maintain.importbasedata.service.ExportBasedataManager,com.forgon.tools.SpringBeanManger"%> +<%@ page contentType="text/html; charset=UTF-8"%> +<% +String fileName="基础数据导出.xls"; +out.clear(); +out = pageContext.pushBody(); +ServletOutputStream servletOutputStream = response.getOutputStream(); +response.setContentType("application/octet-stream"); +response.addHeader("Content-Disposition","attachment;filename=" + new String(fileName.getBytes("GBK"), "ISO-8859-1")); +ExportBasedataManager exportBasedataManager = (ExportBasedataManager)SpringBeanManger.getBean("exportBasedataManager"); +exportBasedataManager.exportBasedataDemo(servletOutputStream); +out.clear(); +out = pageContext.pushBody(); +%> \ No newline at end of file Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/importbasedata/importBasedata.jsp =================================================================== diff -u -r33784 -r36097 --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/importbasedata/importBasedata.jsp (.../importBasedata.jsp) (revision 33784) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/importbasedata/importBasedata.jsp (.../importBasedata.jsp) (revision 36097) @@ -147,6 +147,10 @@ function exportData(){ location.href = "${ctx}/disinfectsystem/basedatamanager/importbasedata/exportBasedata.jsp"; } + +function exportDemo(){ + location.href = "${ctx}/disinfectsystem/basedatamanager/importbasedata/exportBasedataDemo.jsp"; +} function exportZipData(type){ var html = '

正在导出,根据导出内容的大小不同,可能需要等待30-90分钟或者更长时间,请稍候......

'; var url = ''; @@ -262,8 +266,7 @@
  • 取消
  • -
  • 查看文件格式