#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Dosent generate xls(excel) file


    Code:
    public String xls(String filename, String dest_filename){ 
    		try{ 
    		File sourceFile = new File(filename); 
    
    		JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); 
    
    		File destFile = new File(dest_filename); 
    		JRXlsExporter exporter = new JRXlsExporter(); 
    
    		exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    		exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
    		exporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
    		exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
    		exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
    		exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); 
    		exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE); 
    		exporter.exportReport(); 
    
    		} 
    		catch(Throwable t){return "error: " + t.getMessage();} 
    		return "XLS Report generated Successfully!"; 
    		}
    What i cant figure out is that what is the filename and dest_filename in the above snippet.
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,695
    Rep Power
    1958
    Not sure what you mean.
    filename and dest_filename are defined in the function arguments, which means it will be defined the function is being called, based on the parameter used.

    Do you call the function anywhere?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0
    Originally Posted by MrFujin
    Not sure what you mean.
    filename and dest_filename are defined in the function arguments, which means it will be defined the function is being called, based on the parameter used.

    Do you call the function anywhere?
    YES this function is called to generate the xls(excel) format. I cant figure out what parameters does it need to successfully generate a excel file.
  6. #4
  7. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,695
    Rep Power
    1958
    As you can see the variables are use as parameter for the File class.
    You can look at the File documentation to see what it expect.

    But basically, you have to specify a source file (filename) and a destination file (dest_filename).

    What exactly do you want to do?
    have you also looked at the Jasper Report API as well?

IMN logo majestic logo threadwatch logo seochat tools logo