bb

    技术2022-07-10  136

    public class ExcelUtils {

    public static String[] readData() throws EncryptedDocumentException, InvalidFormatException, IOException { String path ="src/test/java/testdata.xlsx"; String[] values = new String[2]; Workbook workbook = WorkbookFactory.create(new File(path)); Sheet sheet = workbook.getSheet("Sheet1"); for (int i = 1; i < 3; i++) { Row row =sheet.getRow(i); Cell cell = row.getCell(0); cell.setCellType(CellType.STRING); values[i-1]=cell.getStringCellValue(); } return values; }

    }

    Processed: 0.013, SQL: 9