Java修改Excel某一列内容
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();}}
}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
