Announcement Announcement Module
Collapse
No announcement yet.
Problem using Excel View Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem using Excel View

    I thought I had followed the examples closely but when I try to download an Excel document I receive the error "File error: data may have been lost" from Excel.

    Here is the code from my subclass of AbstractExcelView:
    Code:
        @Override
        protected void buildExcelDocument(Map map, HSSFWorkbook wb,
                HttpServletRequest request, HttpServletResponse response) throws Exception
        {
            // This is an FTP service class that I built using the Apache Commons
            // Net library.  It works fine, I use it elsewhere with no problems
            FtpService ftp = new FtpService();
    
            // I have omitted some code here that logs on to the FTP service and 
            // determines the path to the Excel document.
                            
            
            InputStream in = ftp.getFileStream(path);               
            wb = new HSSFWorkbook(in);
            
            // This code tests to make sure I have obtained the Excel document and
            // can read the value in the first row, first column.  
            HSSFSheet sheet = wb.getSheetAt(0);
            System.out.println(sheet.getRow(0).getCell(0).getRichStringCellValue());
                    
            in.close();
        }
    The println() in my code shows the correct value for the first row and column in the spreadsheet so I know I am getting the document and creating the workbook successfully. There must be another piece to this that I am missing. Any ideas? Thanks in advance.
Working...
X