Java reads sheet page content in Excel

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.