日期:2014-05-18  浏览次数:20729 次

关于JXL读客户端EXCEL的问题
我写了一段JXL读EXCEL再写入数据库的程序.在服务器端可以读数据,但是在客户段读就提示系统找不到指定的文件
问如何才能读客户端机器上的文件
  public void ExcelInfo(String url,String userid,String rolenum,String cmanagerour) throws BiffException, IOException {
  String path = url;//Excel文件URL
  InputStream is = new FileInputStream (path);//写入到FileInputStream
  Workbook wb = Workbook.getWorkbook (is); //得到工作薄
  Sheet st = wb.getSheet (0);//得到工作薄中的第一个工作表

  String companyname;//客户名
  String linkmanname;//联系人名
  String ctaxnum;
  String ccredit;
  DealString ds = new DealString();
  int RightRows = ds.getRightRows(st);
  for (int i = 1; i < RightRows; i++) {
  Cell[] cell = st.getRow (i);//得到工作表的第一个单元格,即A1
   
  if(cell[0].getType()==CellType.EMPTY){
  companyname = "";
  }else{
  companyname = cell[0].getContents (); }
  if(cell[1].getType()==CellType.EMPTY){
  linkmanname = "";
  }else{
  linkmanname = cell[1].getContents (); }
  if(cell[2].getType()==CellType.EMPTY){
  linkmandepartment = "";
  }else{
  linkmandepartment = cell[2].getContents ();}
  if(cell[3].getType()==CellType.EMPTY){
  linkmanjob = "";
  }else{
  linkmanjob = cell[3].getContents ();}
  }else{
  ccredit = cell[37].getContents ();}
  GetExcelAction ace = new GetExcelAction();
  ace.addCustomerExcel(companyname,getaddress, ctel,cweb, 
  cfax,cothertel, employees,cemail, leadsource,cotheremail, rating, 
  cgrade,cownership, cindustry, annualrevenue, accounttype,
  cnexttime, ccreattime, paycountry,payprovince, paycity,
  payaddress,payzip, getcountry, getprovince, getcity,
  getzip, cbank, caccount,cpaytype, cbname, ctaxnum, ccredit, cmanagerour, rolenum, userid);
  ace.addLinkmanExcel(companyname,linkmanname,linkmandepartment, linkmanjob,linkmanfone, linkmancell, userid,cmanagerour);
  }
  wb.close ();//关闭工作薄
  is.close ();//关闭输入流
  }
  由于限制每个帖子的字数,关于添加进数据库的字段我省去很多

------解决方案--------------------
楼主的思路有问题

你把ReadData.txt放在客户端的任何一台计算机上,你又没有共享给服务器,你让服务器怎么读

正确的做法是客户端把文件上传到服务器,然后服务器读取