在上一篇blog:java的poi技术读取Excel[2003-2007,2010] 中介绍了关于java中的poi技术读取excel的相关操作
读取excel和MysqL相关:
你也可以在 : 了解到写入Excel的方法信息
使用JXL技术 :java的jxl技术导入Excel
本文主要讲的是java中poi读和写excel(版本是2003-2007,2010)
效果:
Processing...lib/201401,name : Hongten,age : 22.0,score : 98.0201402,name : Hanyuan,age : 21.0,score : 96.0201403,name : Tom,age : 20.0,score : 94.0201404,name : HanKet,score : 90.0201405,name : Jone,score : 42.0201406,name : Kite,age : 23.0,score : 59.0201407,name : Lucy,age : 25.0,score : 60.0201408,name : Mark,score : 89.0201409,name : Jeson,age : 24.0,score : 79.0201410,name : Steven,score : 59.0201411,name : Tide,score : 88.0201412,name : Deli,score : 89.0201413,name : Goerme,score : 98.0201414,name : Som,score : 95.0
======================================/201401,score : 95.0
======================================/student_info_2003-2007/======================================/student_info_2003-2007201401,score : 95.0
======================================/201401,score : 95.0
main(String[] args) String read_excel2003_2007_path = String read_excel2010_path =
List list = (list != System.out.println("No. : " + student.getNo() + ",name : " + student.getName() + ",age : " + student.getAge() + ",score : " +score());
System.out.println("======================================"
List list1 = (list1 != System.out.println("No. : " + student.getNo() + ",score : " +score());
System.out.println("======================================" String write_excel2003_2007_path = String write_excel2010_path = System.out.println("======================================"
List list2 = (list != System.out.println("No. : " + student.getNo() + ",score : " +score());
System.out.println("======================================"
List list3 = (list1 != System.out.println("No. : " + student.getNo() + ",score : " +score());
}
String OFFICE_EXCEL_2003_POSTFIX = "xls" String OFFICE_EXCEL_2010_POSTFIX = "xlsx"
String EMPTY = "" String POINT = "." String LIB_PATH = "lib" String STUDENT_INFO_XLS_PATH = LIB_PATH + "/student_info" + POINT + String STUDENT_INFO_XLSX_PATH = LIB_PATH + "/student_info" + POINT + String STUDENT_INFO_XLS_OUT_PATH = "lib/student_info_2003-2007.xls" String STUDENT_INFO_XLSX_OUT_PATH = "lib/student_info_2010.xlsx" String NOT_EXCEL_FILE = " : Not the Excel file!" String PROCESSING = "Processing..." String WRITE_DATA = "write data to file : "
}
hssf.usermodel.hssfCell;
hssf.usermodel.hssfRichTextString;
hssf.usermodel.hssfRow;
hssf.usermodel.hssfSheet;
hssf.usermodel.hssfWorkbook;
usermodel.XSSFCell;
usermodel.XSSFRichTextString;
usermodel.XSSFRow;
usermodel.XSSFSheet;
usermodel.XSSFWorkbook;
writeExcel(List list,String path) (list == } (path == || } String postfix = (! } } System.out.println(path +
aram
List readExcel(String path) (path == || } String postfix = (! } } System.out.println(path +
aram
List readXlsx(String path) System.out.println(Common.PROCESSING + InputStream is = XSSFWorkbook xssfWorkbook = Student student = List list = ArrayList
( numSheet = 0; numSheet < xssfWorkbook.getNumberOfSheets(); numSheet++ XSSFSheet xssfSheet = (xssfSheet ==