Java修改Excel某一列内容

Java修改Excel某一列内容 public class Test {public static void main(String[] args) thro

Java修改Excel某一列内容

public class Test {public static void main(String[] args) throws IOException {IDEA idea = new IDEA();idea.getKey("jx123456");FileInputStream inputStream = null;FileOutputStream outputStream = null;try {inputStream = new FileInputStream("C:\\Users\\Administrator\\Desktop\\2.xlsx");// 根据输入流创建工作簿Workbook workbook = new XSSFWorkbook(inputStream);// 获取表Sheet sheet = workbook.getSheet("SQL Results");int lastRowNum = sheet.getLastRowNum();System.out.println(lastRowNum);for (int i = 1; i <= sheet.getLastRowNum(); i++) {Row row = sheet.getRow(i);if (null == row) {continue;} else {Cell cell = row.getCell(1);if (null == cell) {continue;} else {String stringCellValue = cell.getStringCellValue();System.out.println(stringCellValue);if (stringCellValue.length() == 64) {String desString = idea.getDesString(stringCellValue);System.out.println(desString);cell.setCellValue(desString);}}}}outputStream = new FileOutputStream("C:\\Users\\Administrator\\Desktop\\3.xlsx");workbook.write(outputStream);} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} finally {inputStream.close();outputStream.close();}}
}