You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.dsideal.base.Tools.Test;
import com.dsideal.base.Tools.FillData.ExcelKit.ExcelKit;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class TestRead {
public static void main(String[] args) throws IOException {
//待读取的EXCEL文件
String filePath = "C:\\Users\\Administrator\\全省及州市县区人口与教育报告集20241023\\全省及州市县区人口与教育报告集20241023\\133个县区报告2022\\县区研究报告\\文山州各县市报告8\\马关县\\马关县教育发展规模数据收集表-20240418.xlsx";
//表格正文上方的文字
String keyword = "自动计算招生数、在校生数";
//遍历每个Sheet
for (int k = 0; k < 4; k++) {
//为什么headRows=2?答因为有一行是关键字下一行是表头共2行
//letterIndex=K,表示第二个表格最后一列是字母K
List<List<String>> dataList = ExcelKit.readSecondTable(filePath, k, keyword, 2, "K");
//输出数据
for (int i = 0; i < dataList.size(); i++) {
for (int j = 0; j < dataList.get(i).size(); j++) {
System.out.print(dataList.get(i).get(j) + " ");
}
System.out.println();
}
}
}
}