excel文件读取例子-jxl
2010-12-10 11:48
561 查看
注意版本是: 2003 excel格式
package com.yanek.test;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
String path="C://001.xls";
InputStream in = null;
Workbook workbook = null;
try {
in = read(path);
try {
workbook = Workbook.getWorkbook(in);
Sheet[] sheets = workbook.getSheets();
for (int i = 0; i < sheets.length; i++)
{
int row_count = sheets[i].getRows();
// String auctionCode[] = new String[row_count];
for (int j = 1; j < row_count; j++)
{
// 解析一行数据
Cell[] row = sheets[i].getRow(j);
String auction_code = row[0].getContents().trim();
String name = row[1].getContents().trim();
//codes.add(auction_code);
//System.out.println("auction_code=="+auction_code);
// System.out.println("name=="+name);
// System.out.println("row.length=="+row.length);
int len =row.length;
for (int k=0;k<len;k++)
{
String temp = row[k].getContents().trim();
System.out.println("xxx====:"+temp);
}
}
}
} catch (BiffException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static InputStream read(String localPath)throws Exception
{
InputStream in = null;
try {
in = new FileInputStream(localPath);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return in;
}
}
package com.yanek.test;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
String path="C://001.xls";
InputStream in = null;
Workbook workbook = null;
try {
in = read(path);
try {
workbook = Workbook.getWorkbook(in);
Sheet[] sheets = workbook.getSheets();
for (int i = 0; i < sheets.length; i++)
{
int row_count = sheets[i].getRows();
// String auctionCode[] = new String[row_count];
for (int j = 1; j < row_count; j++)
{
// 解析一行数据
Cell[] row = sheets[i].getRow(j);
String auction_code = row[0].getContents().trim();
String name = row[1].getContents().trim();
//codes.add(auction_code);
//System.out.println("auction_code=="+auction_code);
// System.out.println("name=="+name);
// System.out.println("row.length=="+row.length);
int len =row.length;
for (int k=0;k<len;k++)
{
String temp = row[k].getContents().trim();
System.out.println("xxx====:"+temp);
}
}
}
} catch (BiffException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static InputStream read(String localPath)throws Exception
{
InputStream in = null;
try {
in = new FileInputStream(localPath);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return in;
}
}
相关文章推荐
- JXL 读取 Excel java中jxl导出数据到excel的例子 上传文件
- JXL 读取 Excel java中jxl导出数据到excel的例子 上传文件
- [JAVA] java读取Excel文件内容,jxl(Excel 2003)
- jxl读取指定文件下的所有Excel文件,但是是.xls文件,查的是jxl不支持excel2007
- Java:使用jxl读取excel文件内容
- POI or jxl 在不能读取Excel文件记录时的处理办法之一
- jxl读取excel文件异常:Unable to recognize OLE stream 的解决方法
- 【转载】关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用) - 读取文件
- java用JXL读取excel文件
- OAF_文件系列9_实现OAF解析Excel并读取至数据库JXL
- jxl 读取 excel 文件 占用 CPU 99% 的问题
- jxl读取excel文件中的时间类型
- jxl 读取excel 文件 Unable to recognize OLE stream
- jxl读取excel文件
- Java模块 -- 读取Excel文件写入数据库 Mybatis , POI , JXL
- 通过jxl.jar 读取、导出excel的小例子
- 用jxl读写excel的.xls文件的例子 带样式
- jxl 读取 Excel文件
- java jxl 读取excel文件
- jxl读取excel文件异常:Unable to recognize OLE stream