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 to read and Import Excel by poi Technology of Java

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

In this issue, the editor will bring you how to read and import Java's poi technology into Excel. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

Project structure:

The Excel file used:

XlsMain .java class

/ / this class has a main method, which is mainly responsible for running the program, and it also contains reading Excel with poi (version 2003).

Import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook / * @ author Hongten * * reference address: http://hao0610.iteye.com/blog/1160678 * * / public class XlsMain {public static void main (String [] args) throws IOException {XlsMain xlsMain = new XlsMain (); XlsDto xls = null; List list = xlsMain.readXls () Try {XlsDto2Excel.xlsDto2Excel (list);} catch (Exception e) {e.printStackTrace ();} for (int I = 0; I < list.size (); iTunes +) {xls = (XlsDto) list.get (I) System.out.println (xls.getXh () + "+ xls.getXm () +" + xls.getYxsmc () + "+ xls.getKcm () +" + xls.getCj ()) }} / * read xls file contents * * @ return List object * @ throws IOException * input / output exception * / private List readXls () throws IOException {InputStream is = new FileInputStream ("pldrxkxxmb.xls"); HSSFWorkbook hssfWorkbook = new HSSFWorkbook (is) XlsDto xlsDto = null; List list = new ArrayList (); / / Circular worksheet Sheet for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets (); numSheet++) {HSSFSheet hssfSheet = hssfWorkbook.getSheetAt (numSheet); if (hssfSheet = = null) {continue } / / Loop line Row for (int rowNum = 1; rowNum

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: 0

*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