PACKAGE&NBSP;COM.BESTPAY.BPBP.BILL.INIT;IMPORT&NBSP;JXL. CELL;IMPORT&NBSP;JXL. SHEET;IMPORT&NBSP;JXL. workbook;import jxl.read.biff.biffexception;import java.io.file;import java.io.ioexception; Public class readexceldatafortestng { private static string parementFile = "E:/test-xiaozhangexception.xls"; private file file; public static string getparementfile () { return parementFile; } public static String Getparementfilenext () { return parementfile; } public readexceldatafortestng (File file) { This.file = file; } public string[][] str (Int sNO) { string[][] str = null; try { workbook book = workbook.getworkbook (file); // get the first sheet object sheet sheet = book.getsheet (SNO); // Get the first row of cells in the first column int col = Sheet.getcolumns ();// get column number int row = Sheet.getrows ();// Get line number str = new string[row-1][col]; for (int i = 0; i < row-1; i++)// cycle for read-write { for (int j = 0; j < col; j++) { cell c = sheet.getcell (j, i+1); str[i][j]= c.getcontents (); } } book.close (); } catch (BiffException e1) { e1.printstacktrace (); } catch (ioexception e) { E.printstacktrace (); } return str; }}
Java reads sheet page content in Excel