| | |
| | | mainSheet.setColumnWidth(16, 0); |
| | | mainSheet.setColumnWidth(17, 0); |
| | | |
| | | // response.setHeader("Content-Disposition", "attachment;filename=测试.xlsx"); |
| | | // response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.mainSheet;charset=utf-8"); |
| | | // |
| | | // // 将工作簿写入响应的输出流 |
| | | // workbook.write(response.getOutputStream()); |
| | | // 隐藏工作表 |
| | | workbook.setSheetHidden(workbook.getSheetIndex(dataSheet), true); |
| | | workbook.setSheetHidden(workbook.getSheetIndex(statusSheet), true); |
| | | workbook.setSheetHidden(workbook.getSheetIndex(prioritySheet), true); |
| | | |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("测试.xlsx", "UTF-8")); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("员工任务分配信息导入表.xlsx", "UTF-8")); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); |
| | | |
| | | // 将工作簿写入响应的输出流 |
| | |
| | | workbook.close(); |
| | | |
| | | workbook.close(); |
| | | // return true; |
| | | // }catch (Exception e) { |
| | | // return false; |
| | | // } |
| | | // try { |
| | | // Workbook workbook = new XSSFWorkbook(); |
| | | // Sheet sheet1 = workbook.createSheet("任务分配信息"); |
| | | // Sheet sheet2 = workbook.createSheet("员工信息"); |
| | | // Sheet sheet3 = workbook.createSheet("任务状态信息"); |
| | | // Sheet sheet4 = workbook.createSheet("优先度信息"); |
| | | // |
| | | // // 在任务分配信息中创建下拉框 |
| | | // XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper((XSSFSheet) sheet1); |
| | | // DataValidationConstraint dvConstraint = dvHelper.createFormulaListConstraint("员工信息!$B$2:$B$100"); |
| | | // DataValidationConstraint dvConstraint1 = dvHelper.createFormulaListConstraint("任务状态信息!$B$2:$B$100"); |
| | | // DataValidationConstraint dvConstraint2 = dvHelper.createFormulaListConstraint("优先度信息!$B$2:$B$100"); |
| | | // |
| | | // // 下拉 |
| | | // CellRangeAddressList addressList1 = new CellRangeAddressList(1, 100, 4, 4); // 所属用户列 |
| | | // CellRangeAddressList addressList2 = new CellRangeAddressList(1, 100, 5, 5); // 任务状态列 |
| | | // CellRangeAddressList addressList3 = new CellRangeAddressList(1, 100, 7, 7); // 优先度列 |
| | | // DataValidation validation = dvHelper.createValidation(dvConstraint, addressList1); |
| | | // DataValidation validation1 = dvHelper.createValidation(dvConstraint1, addressList2); |
| | | // DataValidation validation2 = dvHelper.createValidation(dvConstraint2, addressList3); |
| | | // |
| | | // // 在任务分配信息中添加字段名 |
| | | // Row headerRow1 = sheet1.createRow(0); |
| | | // headerRow1.createCell(0).setCellValue("名称"); |
| | | // headerRow1.createCell(1).setCellValue("任务开始时间"); |
| | | // headerRow1.createCell(2).setCellValue("任务结束时间"); |
| | | // headerRow1.createCell(3).setCellValue("任务工时"); |
| | | // headerRow1.createCell(4).setCellValue("所属员工"); |
| | | //// headerRow1.createCell(5).setCellValue("绩效工时"); |
| | | //// headerRow1.createCell(5).setCellValue("任务进度"); |
| | | // headerRow1.createCell(5).setCellValue("任务状态"); |
| | | // headerRow1.createCell(6).setCellValue("消耗工时"); |
| | | // headerRow1.createCell(7).setCellValue("优先度"); |
| | | // |
| | | // // 在员工信息中添加数据 |
| | | // Row headerRow2 = sheet2.createRow(0); |
| | | // headerRow2.createCell(0).setCellValue("员工姓名"); |
| | | // headerRow2.createCell(1).setCellValue("员工ID"); |
| | | // |
| | | // // 查询数据 |
| | | // List<User> userList = userRepository.findAllByEnabled(true); |
| | | // for (int i = 0; i < userList.size(); i++) { |
| | | // User user = userList.get(i); |
| | | // // 创建数据行 |
| | | // Row row = sheet2.createRow(i + 1); |
| | | // row.createCell(0).setCellValue(user.getNickName()); |
| | | // row.createCell(1).setCellValue(user.getId()); |
| | | // } |
| | | // |
| | | // // 在任务状态信息中添加数据 |
| | | // Row headerRow3 = sheet3.createRow(0); |
| | | // headerRow3.createCell(0).setCellValue("状态名称"); |
| | | // headerRow3.createCell(1).setCellValue("状态代号"); |
| | | // |
| | | // String[][] statuses = { |
| | | // {"未开始", "task_status_not_started"}, |
| | | // {"进行中", "task_status_in_hand"}, |
| | | // {"待测试", "task_status_test"}, |
| | | // {"已暂停", "task_status_stop"}, |
| | | // {"已完成", "task_status_completed"}, |
| | | // {"未承认", "task_status_unrecognized"} |
| | | // }; |
| | | // |
| | | // for (int i = 0; i < statuses.length; i++) { |
| | | // //创建数据行 |
| | | // Row row = sheet3.createRow(i + 1); |
| | | // row.createCell(0).setCellValue(statuses[i][0]); |
| | | // row.createCell(1).setCellValue(statuses[i][1]); |
| | | // } |
| | | // |
| | | // // 在优先度中添加数据 |
| | | // Row headerRow4 = sheet4.createRow(0); |
| | | // headerRow4.createCell(0).setCellValue("优先度名称"); |
| | | // headerRow4.createCell(1).setCellValue("优先度代号"); |
| | | // |
| | | // String[][] yStatuses = { |
| | | // {"低", "priority_low"}, |
| | | // {"中", "priority_middle"}, |
| | | // {"高", "priority_high"} |
| | | // }; |
| | | // |
| | | // for (int i = 0; i < yStatuses.length; i++) { |
| | | // //创建数据行 |
| | | // Row row = sheet4.createRow(i + 1); |
| | | // row.createCell(0).setCellValue(yStatuses[i][0]); |
| | | // row.createCell(1).setCellValue(yStatuses[i][1]); |
| | | // } |
| | | // |
| | | // sheet1.addValidationData(validation); |
| | | // sheet1.addValidationData(validation1); |
| | | // sheet1.addValidationData(validation2); |
| | | //// FileOutputStream fileOut = new FileOutputStream("D:\\11.13测试.xlsx"); |
| | | //// workbook.write(fileOut); |
| | | //// fileOut.close(); |
| | | //// workbook.close(); |
| | | // |
| | | // return true; |
| | | // } catch (Exception e) { |
| | | // return false; |
| | | // } |
| | | |
| | | } |
| | | |
| | | public void addSubTaskUserList(TaskMongo taskMongo, List<Long> containUserList, List<String> taskIds) { |