Java 我正在尝试将一张工作表的第一行与另一张工作表的第一行进行匹配,并检索匹配的数据
我正在尝试将一个工作表的第一行与另一个工作表的第一行匹配,并检索另一个工作表的其余数据Java 我正在尝试将一张工作表的第一行与另一张工作表的第一行进行匹配,并检索匹配的数据,java,excel,apache-poi,Java,Excel,Apache Poi,我正在尝试将一个工作表的第一行与另一个工作表的第一行匹配,并检索另一个工作表的其余数据 sheet=workbook.getSheetAt(1); rowCount=sheet.getPhysicalNumberOfRows(); for (int x=0; x<rowCount; x++) { System.out.println(sheet.getRow(x).getCell(0).getStringCellValue());//--------
sheet=workbook.getSheetAt(1);
rowCount=sheet.getPhysicalNumberOfRows();
for (int x=0; x<rowCount; x++) {
System.out.println(sheet.getRow(x).getCell(0).getStringCellValue());//------------
if (li.get(x).equalsIgnoreCase(sheet.getRow(x).getCell(0).getStringCellValue())) {
//retrieve the data of matching row
}
我已经像这样存储了列表中第一行的数据
int rowCount=sheet.getPhysicalNumberOfRows();
List<String> li=new ArrayList<String>();
for (int x=0; x<rowCount; x++) {
li.add(sheet.getRow(x).getCell(0).getStringCellValue());
}
int rowCount=sheet.getPhysicalNumberOfRows();
List li=new ArrayList();
对于(int x=0;x,我在上一个代码块中看到两个问题:
x是的,存在等式
for (int y=0; y<rowCount; y++) {
System.out.println(li.get(y));
for (int z=0; z<rowCount; z++) {
if (li.get(y).equalsIgnoreCase(sheet.getRow(z).getCell(0).getStringCellValue())) {
XSSFRow row=sheet.getRow(z);
for (int x=1; x<=row.getLastCellNum(); x++) {
System.out.println(row.getCell(x).getStringCellValue());
System.out.println("found");
// break;
}
}
}
}