加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java的poi技术读,写Excel[2003-2007,2010]

发布时间:2020-12-14 06:30:41 所属栏目:Java 来源:网络整理
导读:在上一篇blog: 中介绍了关于java中的poi技术读取excel的相关操作 读取excel和MySQL相关: 你也可以在 : ? 了解到写入Excel的方法信息 使用JXL技术 : java的jxl技术导入Excel? 本文主要讲的是java中poi读和写excel(版本是2003-2007,2010) Processing...l

在上一篇blog:中介绍了关于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 : " + System.out.println("======================================" List list1 = (list1 != System.out.println("No. : " + student.getNo() + ",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 : " + System.out.println("======================================" List list3 = (list1 != System.out.println("No. : " + student.getNo() + ",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 : " }

writeExcel(List list,String path) (list == } (path == || } String postfix = (! } } System.out.println(path + List readExcel(String path) (path == || } String postfix = (! } } System.out.println(path + 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 == ( rowNum = 1; rowNum <= xssfSheet.getLastRowNum(); rowNum++ XSSFRow xssfRow = (xssfRow != student = XSSFCell no = xssfRow.getCell(0 XSSFCell name = xssfRow.getCell(1 XSSFCell age = xssfRow.getCell(2 XSSFCell score = xssfRow.getCell(3 List readXls(String path) System.out.println(Common.PROCESSING + InputStream is = HSSFWorkbook hssfWorkbook = Student student = List list = ArrayList ( numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++ HSSFSheet hssfSheet = (hssfSheet == ( rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++ HSSFRow hssfRow = (hssfRow != student = HSSFCell no = hssfRow.getCell(0 HSSFCell name = hssfRow.getCell(1 HSSFCell age = hssfRow.getCell(2 HSSFCell score = hssfRow.getCell(3 @SuppressWarnings("static-access" (xssfRow.getCellType() == } (xssfRow.getCellType() == } @SuppressWarnings("static-access" (hssfCell.getCellType() == } (hssfCell.getCellType() == } writeXls(List list,String path) (list == countColumnNum = HSSFWorkbook book = HSSFSheet sheet = book.createSheet("studentSheet" HSSFRow firstRow = sheet.createRow(0 HSSFCell[] firstCells = String[] options = { "no","name","age","score" ( j = 0; j < options.length; j++ firstCells[j] = firstCells[j].setCellValue( ( i = 0; i < countColumnNum; i++ HSSFRow row = sheet.createRow(i + 1 Student student = ( column = 0; column < options.length; column++ HSSFCell no = row.createCell(0 HSSFCell name = row.createCell(1 HSSFCell age = row.createCell(2 HSSFCell score = row.createCell(3 File file = OutputStream os = System.out.println(Common.WRITE_DATA + writeXlsx(List list,String path) (list == countColumnNum = XSSFWorkbook book = XSSFSheet sheet = book.createSheet("studentSheet" XSSFRow firstRow = sheet.createRow(0 XSSFCell[] firstCells = String[] options = { "no","score" ( j = 0; j < options.length; j++ firstCells[j] = firstCells[j].setCellValue( ( i = 0; i < countColumnNum; i++ XSSFRow row = sheet.createRow(i + 1 Student student = ( column = 0; column < options.length; column++ XSSFCell no = row.createCell(0 XSSFCell name = row.createCell(1 XSSFCell age = row.createCell(2 XSSFCell score = row.createCell(3 File file = OutputStream os = System.out.println(Common.WRITE_DATA + }

(path == || path.substring(path.lastIndexOf(Common.POINT) + 1 }

.id = .no = .name = .age = setScore( .score = }

========================================================

More reading,and english is important.

I'm Hongten

<pre class="code"><span style="font-size: 16px; color: #ff0000;">大哥哥大姐姐,觉得有用打赏点哦!多多少少没关系,一分也是对我的支持和鼓励。谢谢。Hongten博客排名在100名以内。粉丝过千。Hongten出品,必是精品。

E | hongtenzone@foxmail.com ?B |?

========================================================

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读