FileInputStream file = new FileInputStream(new File("path/to/excel.xlsx")); Workbook workbook = WorkbookFactory.create(file); Sheet sheet = workbook.getSheetAt(0); for (Row row : sheet) { for (Cell cell : row) { String value = cell.getStringCellValue(); System.out.println(value); } } file.close(); FileInputStream file = new FileInputStream(new File("path/to/word.docx")); XWPFDocument document = new XWPFDocument(file); List<XWPFParagraph> paragraphs = document.getParagraphs(); for (XWPFParagraph paragraph : paragraphs) { String text = paragraph.getText(); System.out.println(text); } file.close();


上一篇:
下一篇:
切换中文