Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp crystal reports xls

 
Hugo de la Mora
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, does anyone knows how to export data to Excel from JSP using Crystal Reports, thx in advance.
 
Hugo de la Mora
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my code

<%@ page import="com.crystaldecisions.report.web.viewer.*,
com.crystaldecisions.reports.reportengineinterface.*,
com.crystaldecisions.sdk.occa.report.data.*,
com.crystaldecisions.sdk.occa.report.reportsource.*,
com.crystaldecisions.sdk.occa.report.exportoptions.*" %>

<%
String report = "test3.rpt";

IReportSourceFactory2 rptSrcFactory = new JPEReportSourceFactory();
IReportSource reportSource = (IReportSource)
rptSrcFactory.createReportSource(report, request.getLocale());

try{
ReportExportControl expControl = new ReportExportControl();

ExportOptions exOpts = new ExportOptions();
//exOpts.setExportFormatType(ReportExportFormat.RTF);
//exOpts.setExportFormatType(ReportExportFormat.recordToMSExcel);
exOpts.setExportFormatType(ReportExportFormat.MSExcel);

//RTFWordExportFormatOptions options = new RTFWordExportFormatOptions();
//DataOnlyExcelExportFormatOptions options=new DataOnlyExcelExportFormatOptions();
ExcelExportFormatOptions options = new ExcelExportFormatOptions();

options.setStartPageNumber(1);
options.setEndPageNumber(3);
exOpts.setFormatOptions(options);


expControl.setExportOptions(exOpts);
expControl.setReportSource(reportSource);
expControl.setExportAsAttachment(true);
expControl.setOwnPage(true);
expControl.refresh();
//expControl.processHttpRequest(request, response, config.getServletContext(),out);
expControl.processHttpRequest(request, response,getServletConfig().getServletContext(), null);
expControl.dispose();
}catch(Exception e){out.println(e);}



i'm getting this error
Error
exporterName is empty
what can i do?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm getting this error
Error
exporterName is empty


That is clearly an error being thrown by the code you are calling. You'll need to investigate in what way you are calling it incorrectly.

Since this really has nothing to do with JSP, I've moved it along to the Other Java Products forum.
 
Chandra Mohan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am facing the same problem. I added this but with no effect. Any clue? Thanks in advance,

JPEReportSourceFactory jrsf = new JPEReportSourceFactory();
ExportOptions exOpts = new ExportOptions();
exOpts.setExportFormatType(ReportExportFormat.recordToMSExcel);
//ExcelExportFormatOptions options= new ExcelExportFormatOptions();
DataOnlyExcelExportFormatOptions options=new DataOnlyExcelExportFormatOptions();
options.setMaintainRelativeObjectPosition(true);
options.setExportImages(true);
options.setExportObjectFormatting(true);
options.setMaintainColumnAlignment(true);
options.setExportObjectFormatting(true);
options.setExportPageHeaderAndFooter(true);
options.setUseWorksheetFunctionsForSummaries(true);
options.setBaseAreaType(AreaSectionKind.detail);
exOpts.setFormatOptions(options);
ReportExportControl expViewer = new ReportExportControl();

expViewer.setName("Excel1.xls");
expViewer.setEnableParameterPrompt(true);
expViewer.setExportOptions(exOpts);


expViewer.setReportSource(jrsf.createReportSource("Report.rpt",request.getLocale()));
expViewer.setOwnPage(true);
expViewer.setOwnForm(true);
expViewer.processHttpRequest(request, response, config.getServletContext(),out);
expViewer.dispose();
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic