用jxl从excel批量导入ORACLE出错
网上看了好多打算试一下,我搭了一个ssh框架。包什么都弄好了,然后下了一个jxl.jar包,action里加入下面代码,错误出现了,调试走到获取excal文件处就走不了了...
网上看了好多打算试一下,我搭了一个ssh框架。包什么都弄好了,然后下了一个jxl.jar包,action里加入下面代码,错误出现了,调试走到获取excal文件处就走不了了
代码如下:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
try{
Workbook workbook = Workbook.getWorkbook(new File("d:/tmp001.xls"));
Sheet sheet = workbook.getSheet(0);
System.out.println(sheet.toString());
int rows=sheet.getRows();
for(int i=1;i<rows;i++){
TestHlAsset asset=null;
asset.setTHlAssetlistId(sheet.getCell(1,i).getContents());
asset.setTHlAssetlistName(sheet.getCell(2,i).getContents());
//AssetlistForm Aform= (AssetlistForm)form;
//asset=Aform.getAssetlist();
assetlistBiz.insertTestHlAssetlistId(asset);
}
}catch(IOException ioex){
System.out.println("saleDeptToDB read file Error: "+ioex);
}catch(BiffException biffex)
{
System.out.println(biffex);
}
return mapping.findForward("success");
} 展开
代码如下:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
try{
Workbook workbook = Workbook.getWorkbook(new File("d:/tmp001.xls"));
Sheet sheet = workbook.getSheet(0);
System.out.println(sheet.toString());
int rows=sheet.getRows();
for(int i=1;i<rows;i++){
TestHlAsset asset=null;
asset.setTHlAssetlistId(sheet.getCell(1,i).getContents());
asset.setTHlAssetlistName(sheet.getCell(2,i).getContents());
//AssetlistForm Aform= (AssetlistForm)form;
//asset=Aform.getAssetlist();
assetlistBiz.insertTestHlAssetlistId(asset);
}
}catch(IOException ioex){
System.out.println("saleDeptToDB read file Error: "+ioex);
}catch(BiffException biffex)
{
System.out.println(biffex);
}
return mapping.findForward("success");
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询