需要在数据表的最后一列中将数据写入标头和值

时间:2019-06-25 11:22:52

标签: java excel selenium-webdriver

enter image description here

        FileInputStream file = new FileInputStream(
                    new File(System.getProperty("user.dir") + "\\Data\\ReturnsAndReplacementsEcomm.xlsx"));

        XSSFWorkbook workbook = new XSSFWorkbook();
        XSSFSheet sheet = workbook.getSheet("TestData");

        int lastRow = sheet.getLastRowNum();
        XSSFCell cell = sheet.getRow(lastRow).createCell(lastRow);
        cell.setCellValue("ReturnReference");

        cell = sheet.getRow(lastRow).createCell(lastRow);
        cell.setCellValue(ReturnReference);

        file.close();

        FileOutputStream outFile = new FileOutputStream(
                new File(System.getProperty("user.dir") + "\\Data\\ReturnsAndReplacementsEcomm.xlsx"));
        workbook.write(outFile);

        outFile.close();

0 个答案:

没有答案