Java Operation Excel File

Source: Internet
Author: User

Http://www.cnblogs.com/wuxinrui/archive/2011/03/20/1989326.html

ImportJava.io.File;ImportJXL. Cell;ImportJXL. Sheet;ImportJXL. Workbook; Public classReadexcel { Public Static voidMain (string[] args) {Try {            //Create workbook directly from a local file (. xls)String excelfile = "Book1.xls"; Workbook Workbook= Workbook.getworkbook (NewFile (excelfile)); //get the first sheet tableSheet rs = workbook.getsheet (0); //Once you get the sheet, you can access Excel cell (term: cell) through it. //step three: accessing cell cell//gets the first row, the value of the first columnCell c00 = Rs.getcell (0, 0); String strc00=c00.getcontents (); //gets the value of the first row, the second columnCell C10 = Rs.getcell (1, 0); String STRC10=c10.getcontents (); //Gets the second row, the value of the second columnCell C11 = Rs.getcell (1, 1); String Strc11=c11.getcontents (); System.out.println ("Cell (0, 0)" + "value:" + strc00 + "; Type: "+C00.gettype ()); System.out.println ("Cell (1, 0)" + "value:" + STRC10 + "; Type: "+C10.gettype ()); System.out.println ("Cell (1, 1)" + "value:" + Strc11 + "; Type: "+C11.gettype ()); //gets the fourth row, the value of the first columnCell c03 = Rs.getcell (0,3); System.out.println ("Line fourth, the value of the first column:" +c03.getcontents ()); String Contents= Rs.getcell (0,4). getcontents ();//get an empty stringSystem.out.println ("line fifth, value of first column:" +contents); String S44= Rs.getcell (3, 3). getcontents ();                                System.out.println (S44); } Catch(Exception e) {e.printstacktrace (); }            }}

Java Operations Excel file

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.