日期:2014-05-20  浏览次数:20681 次

用JAVA将EXCEL文件解析存入ORACLE数据库

用用JAVA实现将EXCEL文件解析存入ORACLE数据库
大家有好的办法吗?请高手指点一下,谢谢!

------解决方案--------------------
poi读取excel文件,执行业务后存入oracle
------解决方案--------------------
标记下 有空 解决这个 现在忙
------解决方案--------------------
2楼正解
------解决方案--------------------
用jxl也行
------解决方案--------------------
用jxl的优势可能要比poi好一点,我建议是使用jxl
------解决方案--------------------
jxl
------解决方案--------------------
楼主可以试一下jxls 是一个支持excel模板填充的开源软件
------解决方案--------------------
有一个将excel文件转换成文本的例子,参考

import jxl.*;
import java.io.*;
import java.util.*;

public class ExcelToTxt 
{
private String filePath=""; ///文件路径
private InputStream inputStream; ///输入流

private Workbook workbook; ///excel文件
private Sheet sheet; ///sheet
private Cell cell; ///元素
private String znkh; ///智能卡号
List list = new ArrayList();
private int rowCount; ///行总数
private int colCount=30; ///列总数
private int colIndex; ///列
static public String vStr = ""; ///信息

public ExcelToTxt()
{
}

public ExcelToTxt(File file) {

try{
inputStream = new FileInputStream(file);
}catch(Exception e){
System.err.println("*****************ImportZnk manager is error!******"+e.getMessage());
}
}

public void setInputStream(File file){
try{
inputStream = new FileInputStream(file);
}catch(Exception e){
System.err.println("*************ImportZnk setInputStream is error!******"+e.getMessage());
}
}

private void getworkBook(){
try{
workbook = Workbook.getWorkbook(inputStream); 
inputStream.close();
}catch(Exception e){
e.printStackTrace();
}
}

private void getsheet(){
if (workbook == null)
getworkBook();
sheet = workbook.getSheet(0);
}

public int getrowCount(){
if (sheet == null)
{getsheet();}
rowCount = sheet.getRows();

return rowCount;
}
public int getcolCount() {
return sheet.getColumns();
}
/*
public List getZnkh(int rowIndex){
if (sheet == null)
{getsheet();}
for(int i=0;i<colCount;i++){
cell = sheet.getCell(i,rowIndex);
znkh = cell.getContents();
list.add(i,znkh);
}
return list;
}
*/
public String getCell(int rowIndex,int colIndex) {
cell = sheet.getCell(colIndex,rowIndex);
return cell.getContents();
}

public void workbookClose(){
if(workbook != null){
workbook.close();
}
}
public static void main(String[] args) throws Exception
{

String outFilePath = "d:\\cxt\\outr.txt"; //输出文件
File outFile = new File(outFilePath);
FileWriter o = new FileWriter(outFilePath);
String filePath="d:\\cxt\\memberr20060904.xls" ;