Jump to content
We've recently updated our Privacy Statement, available here ×

excel sheet_names


pkozak

Recommended Posts

Hi

 

I want to export data using jr to xls format, but I want to have all data on one page, so I do

exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);

 

but then I've got error because jr sheet name is improper

 

Does instruction

exporter.setParameter(JRXlsExporterParameter.SHEET_NAMES, new String[]{"Sheet1"}

only work in case when pages are on separate sheet?

 

Thanks in advance

PK

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

 

I don't know if you received my first answer, because I see this wasn't saved on the main page. I try to answer again.

If you've set correctly IS_ONE_PAGE_PER_SHEET, and SHEET_NAMES parameters, usually there are no problems. Your single sheet should be named "Sheet1", indeed.

Anyway, if you don't care about the sheet name, the SHEET_NAMES parameter is not required. If you don't set it,the sheet name will be a clone of the document's name.

If you still have this problem, please send us your exactly piece of code, and eventually the generated error stacktrace.

 

Hope to be helpful,

sanda

Link to comment
Share on other sites

Hi

thanks for reply

 

there is my code below

 

Code:

public void exportToXLS(String fileName) throws ReportGenerationException {
log.debug(">>"«»);
try {
File destFile = new File(fileName);
JRXlsExporter exporter = new JRXlsExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());
exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporter.setParameter(JRXlsExporterParameter.IS_FONT_SIZE_FIX_ENABLED, Boolean.FALSE);
exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,
Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.SHEET_NAMES, new String[] { "Sheet1" });

exporter.exportReport();
if (log.isDebugEnabled()) {
log.debug("nazwa pliku raportu: " + fileName);
log.debug("<<"«»);
}
} catch (JRException jre) {
throw new ReportGenerationException("JRException Exception encountered", jre);
}

}

 

the name of the only one sheet of generated xls is

name of jasper template without .jasper (not "Sheet1")

 

Any suggestions?

 

Thanks in advance

PK

Link to comment
Share on other sites

Hi,

 

I see all parameters were set correctly. In this case I think is possible that you use an older version of jasperreports. You can get the newest 1.3.0 version from downloads page.

http://www.jasperforge.org/index.php?option=com_content&task=section&id=16&Itemid=277

If the problem persist, please send us the error stacktrace (if there is one). Also it is important to know which Excel version you used.

 

Let me know,

sanda

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...