如何验证字符串及其在 excel 到 Java 中的值?

How to Validate the String and it's Value in excel through Java?

我是 Java 的新手,我在验证 excel 方面遇到挑战 file.Please 帮助我。

我想验证 'Hyderabad' 是位置名称,'1' 是从 excel(请在下方截图)到 JAVA 的位置 ID。我能够阅读所有内容单元格 values.But 我想验证 Location Name 是否为 Hyderabad(同样,位置 ID)。请在此处建议我。

if (fileType.equalsIgnoreCase("Excel")) {
            Workbook wb = new XSSFWorkbook(f);

            for (int i = 0; i < wb.getNumberOfSheets(); i++) {

                System.out.println("Sheet name: " + wb.getSheetName(i));
                Sheet sh=wb.getSheetAt(i);

                if (wb.getSheetName(i).matches("A|B|C|D"))
                {
                    int rowCount = sh.getLastRowNum() - sh.getFirstRowNum();

                    for (int j = 0; j < rowCount + 1; j++) {

                        Row row = sh.getRow(j);

                        for (int k = 0; k < row.getLastCellNum(); k++) {

                            System.out.print(row.getCell(k).getStringCellValue() + "|| ");

                        }
                }
            }

        }

if (fileType.equalsIgnoreCase("Excel")) { 工作簿 wb = new XSSFWorkbook(f);

        for (int i = 0; i < wb.getNumberOfSheets(); i++) {

            System.out.println("Sheet name: " + wb.getSheetName(i));
            Sheet sh=wb.getSheetAt(i);

            if (wb.getSheetName(i).matches("A|B|C|D"))
            {
                int rowCount = sh.getLastRowNum() - sh.getFirstRowNum();

                for (int j = 0; j < rowCount + 1; j++) {

                    Row row = sh.getRow(j);


                    if(row.getCell(0).getStringCellValue().contains("Location Name")){
                    {
                        if(row.getCell(1).getStringCellValue().equalsIgnoreCase("Hydrabad")){
                            System.out.print("Location name is matches with Hydrabad");
                        }
                        else{
                            System.out.print("Location name isn't matches with Hydrabad");
                        }
                    }

                    if(row.getCell(0).getStringCellValue().contains("Location ID")){
                    {
                        if(row.getCell(1).getStringCellValue().equalsIgnoreCase("1")){
                            System.out.print("Location id matches");
                        }
                        else{
                            System.out.print("Location id mismatches");
                        }
                    }
            }

    }