Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Java uses POI to operate Excel

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how Java uses POI to operate Excel, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Java uses POI to operate Excel1. POI operates Excel1.1. Depends on org.apache.poi poi 4.1.0 org.apache.poi poi-ooxml 4.1.0 org.apache.poi poi-ooxml-schemas 4.1.0 1.2. Read Excel1.2.1. Excel file content

1.2.2. Code / * read excel * / public static void readExcel () {InputStream inputStream = null; XSSFWorkbook xssfWorkbook = null; try {String past = "/ Operation excel.xlsx"; inputStream = new FileInputStream (past); xssfWorkbook = new XSSFWorkbook (inputStream); / / get the number of sheet int numberOfSheets = xssfWorkbook.getNumberOfSheets () / / get the specified sheet System.out.println (numberOfSheets); / / get XSSFSheet sheet = xssfWorkbook.getSheet ("notebook") by specifying the name; / / get XSSFSheet sheetAt = xssfWorkbook.getSheetAt (1) by subscript If (sheetAt! = null) {/ / the last row with data int lastRowNum = sheetAt.getLastRowNum (); XSSFRow row; short lastCellNum; XSSFCell cell; for (int I = 0; I

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 277

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report