【自动化__持续集成】___java___excel__jxl读

一、代码如下

package com.wujianbo.five;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.demo.Demo;
import jxl.read.biff.BiffException;

public class Demo05 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Demo05 demo05= new Demo05();
		demo05.readExcelByJxl();

	}

	public void readExcelByJxl() {
		String path= System.getProperty("user.dir");
		path= path + "\\data\\Students.xls";
		//System.out.println(path);
		try {
			File file= new File(path);
			FileInputStream fis= new FileInputStream(file);
			jxl.Workbook rwb= Workbook.getWorkbook(fis);

			Sheet[] sheet= rwb.getSheets();
			for(int i=0; i<sheet.length; i++) {
				Sheet rs= rwb.getSheet(i);
				for(int j=0; j<rs.getRows(); j++) {
					Cell[] cells= rs.getRow(j);
					for(int k=0;k<cells.length; k++) {
						System.out.print(cells[k].getContents());
						System.out.print("\t");

					}
					System.out.println();

				}
			}
			fis.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (BiffException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IndexOutOfBoundsException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
时间: 2024-11-08 17:27:11

【自动化__持续集成】___java___excel__jxl读的相关文章

【自动化__持续集成】___java___XMl___DOM读

一.代码如下 package com.wujianbo.five; import javax.sound.midi.Sequence; import javax.xml.bind.Element; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import

【自动化__持续集成】___java___excel__jxl改

一.代码如下 package com.wujianbo.five; import java.awt.HeadlessException; import java.awt.Label; import java.io.File; import java.io.IOException; import jxl.Workbook; import jxl.read.biff.BiffException; import jxl.write.WritableSheet; import jxl.write.Wri

【自动化__持续集成】___java___excel__jxl写

一.代码如下 package com.wujianbo.five; import java.io.File; import java.io.IOException; import org.apache.poi.ddf.EscherColorRef.SysIndexSource; import jxl.Workbook; import jxl.write.Label; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook

【自动化__持续集成】___java___List

一.代码如下 package www.wujianbotwo; import java.util.*; public class Demo07 { public static void main(String[] args) { // TODO Auto-generated method stub List mylist= new List(); } } package www.wujianbotwo; import java.util.*; public class Demo07 { publ

【自动化__持续集成】___java___文本文件__字节流

一.代码如下 package www.wujianbotwo; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; public class Demo09 { public static void main(String[] args) { // TODO

【自动化__持续集成】___java___字符串转数组

一.代码如下 package www.wujianbotwo; public class Demo08 { public static void main(String[] args) { // TODO Auto-generated method stub String content= "wujianbo,wujianob,33333"; String[] ud= content.split(",");//将字符串分段成一个数组 for(int i=0; i&l

【自动化__持续集成】___java___重写

一.代码如下 package www.wujianbotwo; class Door { int height= 200; int weight= 80; String material= "实木"; private void open() { // TODO Auto-generated method stub System.out.println("开门"); } public void close() { // TODO Auto-generated meth

【自动化__持续集成】___java___继承

一.代码如下 package www.wujianbotwo; class Door { int height= 200; int weight= 80; String material= "实木"; public void open() { // TODO Auto-generated method stub System.out.println("开门"); } public void close() { // TODO Auto-generated metho

【自动化__持续集成】___java___正则表达式

一.代码如下 package com.wujianbo.five; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Demo01 { public static void main(String[] args) { // TODO Auto-generated method stub String phone= "13541433525"; String phoneEx= &quo