This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

No field names in jsper report page

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm using the following inorder to print a report using an xml file that was build using iReport.
It prints the report but I have 2 questions if I may:
1. How can I show field name in the grey area of the report beneath the title, so one would know what is the name of the column? now its a blank grey row.
2. If I have namy fields to print Can I set the report to be devided to 2 or 3 so all the fields will be shown? Now it shows all fields in the same A4 page so it go's one on top of each other.
public static void PrintReport(int reportID,String printerDescription){
try
{
Report currReport = ReportsManager.instance().getReport(reportID);
String xmlFileName = Configuration.instance().getReportTemplateFilesFolder() + File.separator + currReport.getFilename();
PrintService selectedPrintService = ReportsManager.instance().getPrintService(printerDescription);

if (selectedPrintService != null) {
PrintServiceAttributeSet printAttributeSet = selectedPrintService.getAttributes();
ByteArrayOutputStream compiledOutput = new ByteArrayOutputStream();
JasperCompileManager.compileReportToStream(new FileInputStream(xmlFileName), compiledOutput);
Map parameters = new HashMap();

ByteArrayInputStream in = new ByteArrayInputStream(compiledOutput.toByteArray());

JasperPrint jasperPrint = JasperFillManager.fillReport(in, parameters, Database.instance().getConnection());

JRAbstractExporter printExporter = new JRPrintServiceExporter();
printExporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
printExporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, new Boolean(false));
printExporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, new Boolean(false));
printExporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printAttributeSet);
printExporter.exportReport();
}
}
catch (JRException e)
{
e.printStackTrace();
System.exit(1);
}
catch (ModelException me) {
logger.error("", me);
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
note:
When I'm displaying the report as PDF It shows the field names and also prints it if I print it from the PDF itself But by printing directly it doesn't.
Please advise
Thanks
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!