he2802 3 роки тому
батько
коміт
6621122f46

+ 2 - 2
zhongzheng-common/pom.xml

@@ -115,8 +115,8 @@
         </dependency>
         <dependency>
             <groupId>org.apache.poi</groupId>
-            <artifactId>ooxml-schemas</artifactId>
-            <version>1.1</version>
+            <artifactId>poi-ooxml-schemas</artifactId>
+            <version>4.1.0</version>
         </dependency>
 
             <!-- yml解析器 -->

+ 9 - 10
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -338,24 +338,23 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         try{
             String path = file.getOriginalFilename();
             if (path.endsWith(".doc")) {
-                InputStream is = file.getInputStream();
-
+                throw new CustomException("不支持doc格式");
+                /*InputStream is = file.getInputStream();
                 WordExtractor wordExtractor = new WordExtractor(is);
                 buffer = wordExtractor.getText();
-                wordExtractor.close();
-                System.out.println("CC");
-                System.out.println(buffer);
+                wordExtractor.close();*/
             } else if (path.endsWith("docx")) {
-                OPCPackage opcPackage = POIXMLDocument.openPackage(path);
-                POIXMLTextExtractor extractor = new XWPFWordExtractor(opcPackage);
+                InputStream is = file.getInputStream();
+                XWPFDocument doc = new XWPFDocument(is);
+                XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
                 buffer = extractor.getText();
                 extractor.close();
-                System.out.println(buffer);
+
             } else {
-                System.out.println("此文件不是word文件!");
+                throw new CustomException("请导入word文件!");
             }
         }catch (Exception e){
-
+            System.out.println("此文件不是word文件!A"+e.getMessage());
         }
 
     }