Objective
Report output is often involved in Java application development, while general reports often lack generality, which makes it inconvenient for users to personalize editing. Because of its cross-platform features, Java programs cannot manipulate Excel directly. Therefore, this article explores the POI line of Sight Java program for the number of columns and rows in Excel reading.
Methods are as follows
Gets the specified row, with the index starting at 0
Hssfrow=hssfsheet.getrow (1);
Gets the specified column, with the index starting at 0
Hssfcell=hssfrow.getcell ((short) 6);
Gets the total number of
//int rownum=hssfsheet.getlastrownum ();
Gets the total number of records in an Excel table
int rownum=storageslist.size ();
Gets the total number of columns
int columnnum=hssfrow.getphysicalnumberofcells ();
FileInputStream INP = new FileInputStream ("E:\\weian.xls");
Hssfworkbook wb = new Hssfworkbook (INP);
Hssfsheet sheet = wb.getsheetat (2); Get a third workbook (2008 workbook)
//Fill the above table, the data needs to be queried from the database
hssfrow row5 = Sheet.getrow (4);//Get the fifth line of the workbook
Hssfcell cell54 = Row5.getcell (3);//Get Fourth cell
cell54.setcellvalue ("Test taxpayer name") on line fifth;//Assign value to cell
//Get total number of columns
int coloumnum= Sheet.getrow (0). Getphysicalnumberofcells ();
int Rownum=sheet.getlastrownum ();//Get total number of rows
Summarize
The above is the entire content of this article, I hope the content of this article for everyone to learn or use Java can bring some help, if you have questions you can message exchange.