操作excel
static void create(String path) throws Exception {//讀取文件FileInputStream in = new FileInputStream(path);XSSFWorkbook wb = new XSSFWorkbook(in);// 獲得該工作區的第一個sheetXSSFSheet sheet = wb.getSheetAt(0);int rowNum = sheet.getLastRowNum();//行int columnNum = sheet.getRow(0).getPhysicalNumberOfCells();//列System.out.println(rowNum + "條數據," + columnNum + "列");XSSFRow row;String bm;String mm;for (int i = 1; i <= rowNum; i++) {row = sheet.getRow(i);//讀取值bm = (long) row.getCell(0).getNumericCellValue() + "";mm = jia(bm);//設置值row.getCell(4).setCellValue(mm);System.out.println(mm);}//另存為FileOutputStream out = new FileOutputStream("/Users/1111/Desktop/112000000.xlsx");//寫出
wb.write(out);out.close();}
以上程序使用poi讀取excel表2007,修改值,另存一份。?
?
轉載于:https://www.cnblogs.com/chenglc/p/8313048.html
總結
- 上一篇: Introducing the Clea
- 下一篇: 看完吴恩达(Andrew Ng)机器学习