代码之家  ›  专栏  ›  技术社区  ›  Aaliya

通过JSPDynpage从excel数据中读取数据

  •  0
  • Aaliya  · 技术社区  · 12 年前

    请帮助我解决以下问题。 我必须从excel中读取数据。 我已经创建了JSPDynpage组件,并遵循以下链接: http://help.sap.com/saphelp_sm40/helpdata/en/63/9c0e41a346ef6fe10000000a1550b0/frameset.htm 下面是我的代码。我正在尝试使用apache poi 3.2 API读取excel文件

        try 
    {
    
    FileUpload fu = (FileUpload) 
                            this.getComponentByName("myfileupload");
    
             //    this is the temporary file
             if (fu != null) {
                 //    Output to the console to see size and UI.
                 System.out.println(fu.getSize());
                 System.out.println(fu.getUI());
                 //    Get file parameters and write it to the console
                 IFileParam fileParam = fu.getFile();
                 System.out.println(fileParam);
                 //    Get the temporary file name
                 File f = fileParam.getFile();
                 String fileName = fileParam.getFileName();
                 //    Get the selected file name and write ti to the console
                 ivSelectedFileName = fu.getFile().getSelectedFileName();
    File fp = new File(ivSelectedFileName);
      myLoc.errorT("#fp#"+fp);
      try {
    //
    
      **FileInputStream file = new FileInputStream(fp);**   --> error at this line
    
      HSSFWorkbook workbook = new HSSFWorkbook(file);
    
      myLoc.errorT("#workbook#"+workbook);
    //Get first sheet from the workbook
      HSSFSheet sheet = workbook.getSheetAt(0);
      myLoc.errorT("#sheet#"+sheet);
    
    
    
    
    //
      } catch(Exception ioe) {
      myLoc.errorT("#getLocalizedMessage# " + ioe.getLocalizedMessage());
      }
    
    
    Error :
    #getLocalizedMessage# C:\Documents and Settings\10608871\Desktop\test.xls (The system cannot find the path specified)
    at line      FileInputStream file = new FileInputStream(fp);
    
    
    
    I have created the PAR file and deploying it on server.
    
    Thanks in Advance,
    Aliya Khan.
    
    1 回复  |  直到 12 年前
        1
  •  0
  •   Aaliya    12 年前

    我解决了这个问题,我传递了wong参数而不是f FileInputStream文件=新的FileInputStream(f);

    推荐文章