Чтение данных таблиц из файлов Docx


1

public class ReadTableWord {
 static String temp = "";
static String cellValue;
	public static void main(String[] args) throws IOException {
		
		
		File file = new File("D:/Test111/BRD-+machine-usage+updation.docx");
		FileInputStream fis = new FileInputStream(file);
		XWPFDocument doc = new XWPFDocument(fis);
		List<XWPFTable> tables = doc.getTables();
	
		for (XWPFTable table : tables) {
			for (XWPFTableRow row : table.getRows()) {
				for (XWPFTableCell cell : row.getTableCells()) {
					System.out.println(cell.getText());
					String sFieldValue = cell.getText();
					if (sFieldValue.matches("Whatever you want to match with the string") || sFieldValue.matches("Approved")) {
						System.out.println("The match as per the Document is True");
					}
//					System.out.println("	");
				}
				System.out.println(" ");
			}
		}
		
	}

}


Это правильный ответ.


Java, Apache-то,

java,apache-poi,

-3

Ответов: 1


1

public class ReadTableWord {
 static String temp = "";
static String cellValue;
	public static void main(String[] args) throws IOException {
		
		
		File file = new File("D:/Test111/BRD-+machine-usage+updation.docx");
		FileInputStream fis = new FileInputStream(file);
		XWPFDocument doc = new XWPFDocument(fis);
		List<XWPFTable> tables = doc.getTables();
	
		for (XWPFTable table : tables) {
			for (XWPFTableRow row : table.getRows()) {
				for (XWPFTableCell cell : row.getTableCells()) {
					System.out.println(cell.getText());
					String sFieldValue = cell.getText();
					if (sFieldValue.matches("Whatever you want to match with the string") || sFieldValue.matches("Approved")) {
						System.out.println("The match as per the Document is True");
					}
//					System.out.println("	");
				}
				System.out.println(" ");
			}
		}
		
	}

}


Это правильный ответ.


Java, Apache-то,
Похожие вопросы