| | |
| | | |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | String dataPath = "D:\\测评系统\\需求\\2023\\5.领导潜力报告\\report\\LAQ表头数据文件.xlsx"; |
| | | /* String dataPath = "D:\\测评系统\\需求\\2023\\5.领导潜力报告\\report\\LAQ表头数据文件.xlsx"; |
| | | // 获取导入数据 |
| | | File file = new File(dataPath); |
| | | InputStream in = new FileInputStream(file); |
| | |
| | | // String zipFileName = WordUtil.makeReportFile("D:\\测评系统\\需求\\LAQ\\report\\LAQ英文报告-20230926.docx", template, textMap, new HashMap<>(), deleteStrList); |
| | | // fileNameList.add(zipFileName); |
| | | ZipSecureFile.setMinInflateRatio(0.001); |
| | | try (OutputStream os = new FileOutputStream("D:\\测评系统\\需求\\2023\\5.领导潜力报告\\report\\LAQ编译报告英文.docx");XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage("D:\\测评系统\\需求\\2023\\5.领导潜力报告\\report\\LAQ英文版.docx"))){ |
| | | try (OutputStream os = new FileOutputStream("D:\\测评系统\\需求\\2023\\5.领导潜力报告\\report\\LAQ编译报告.docx");XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage("D:\\测评系统\\需求\\2023\\5.领导潜力报告\\report\\LAQ中文模板.docx"))){ |
| | | Map<Integer,List<SeriesData>> seriesDatas = initData(textMap); |
| | | changeChart(document,seriesDatas,textMap); |
| | | document.write(os); |
| | |
| | | |
| | | log.info("删除的文件名:{}", JSON.toJSONString(deleteStrList)); |
| | | WordUtil.deleteFileByStr(deleteStrList); |
| | | } |
| | | }*/ |
| | | } |
| | | |
| | | /** |
| | | * 替换LAQ图表数据 |
| | | * @param document 文档对象 |
| | | * @param textMap 数据源 |
| | | */ |
| | | public static void changeChart(XWPFDocument document, Map<String, Object> textMap) { |
| | | Map<Integer,List<SeriesData>> seriesDatas = initData(textMap); |
| | | changeChart(document,seriesDatas,textMap); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param textMap |
| | | * @return |
| | | */ |
| | | public static Map<Integer,List<SeriesData>> initData(Map<String, String> textMap){ |
| | | public static Map<Integer,List<SeriesData>> initData(Map<String, Object> textMap){ |
| | | Map<Integer,List<SeriesData>> seriesDataMap = new HashMap<>(); |
| | | //获取命中数值 |
| | | Double olas = Double.valueOf(textMap.get("olas")); |
| | | Double ca = Double.valueOf(textMap.get("ca")); |
| | | Double bla = Double.valueOf(textMap.get("bla")); |
| | | Double nr = Double.valueOf(textMap.get("nr")); |
| | | Double ar = Double.valueOf(textMap.get("ar")); |
| | | Double open = Double.valueOf(textMap.get("open")); |
| | | Double cons = Double.valueOf(textMap.get("cons")); |
| | | Double extra = Double.valueOf(textMap.get("extra")); |
| | | Double agree = Double.valueOf(textMap.get("agree")); |
| | | Double emosta = Double.valueOf(textMap.get("emosta")); |
| | | Double olas = Double.valueOf((String)textMap.get("olas")); |
| | | Double ca = Double.valueOf((String)textMap.get("ca")); |
| | | Double bla = Double.valueOf((String)textMap.get("bla")); |
| | | Double nr = Double.valueOf((String)textMap.get("nr")); |
| | | Double ar = Double.valueOf((String)textMap.get("ar")); |
| | | Double open = Double.valueOf((String)textMap.get("open")); |
| | | Double cons = Double.valueOf((String)textMap.get("cons")); |
| | | Double extra = Double.valueOf((String)textMap.get("extra")); |
| | | Double agree = Double.valueOf((String)textMap.get("agree")); |
| | | Double emosta = Double.valueOf((String)textMap.get("emosta")); |
| | | |
| | | // 图表1 |
| | | List<SeriesData> seriesDatas = Arrays.asList( |
| | |
| | | * @param seriesDataMap |
| | | * @param textMap 数据源 |
| | | */ |
| | | public static void changeChart(XWPFDocument document, Map<Integer,List<SeriesData>> seriesDataMap, Map<String, String> textMap) { |
| | | public static void changeChart(XWPFDocument document, Map<Integer,List<SeriesData>> seriesDataMap, Map<String, Object> textMap) { |
| | | if(StringUtils.isEmpty(textMap)){ |
| | | return; |
| | | } |