0

我有一个 excelsheet,其中有类似这样的数据,我的要求是读取 excelsheet 并获取具有下拉类型的 screen_name,这是我的示例输入,我还添加了可用作参考的输出

Seq     Screen_name        Type     
1.0     ds_top             dropdown     
2.0     ds_level            detail  

输出将是:- ds_top

我能够读取 excelfile 并获取 screen_names 的列值并单独输入,但是如何实现进一步的逻辑

任何帮助表示赞赏

   import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

    public class ReadCellExample {
        String xlsxFile = "/home/spec.xlsx";
    
        public static void main(String[] args) throws IOException {
            ReadCellExample rc = new ReadCellExample();
             rc.ReadCellData(1, 1, 2);
        }
    
        public void ReadCellData(int vRow, int vColumn, int columndef) throws IOException {
            String value = null;
            Workbook wbook = null;
            FileInputStream fis = new FileInputStream(xlsxFile);
            wbook = new XSSFWorkbook(fis);
            Sheet sheet = wbook.getSheetAt(0);
            Row row = sheet.getRow(vRow);
            for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
                row = sheet.getRow(rowIndex);
                Cell cell = row.getCell(vColumn);
                value = cell.getStringCellValue();
            }
            for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
                row = sheet.getRow(rowIndex);
                Cell cell = row.getCell(columndef);
                value = cell.getStringCellValue();
            }
        }
    }
4

0 回答 0