Link to home
Create AccountLog in
Avatar of craigyang
craigyang

asked on

Export web Crystal Reports XI to Excel

How to export web Crystal Reports XI to Excel? The export option of Excel doesn't show up on my web Crystal Report. My code is as follows :

String reportName = "1308_001.rpt";
Object reportSource = new Object();
//---------- Create a ReportClientDocument ----------
ReportClientDocument oReportClientDocument = new ReportClientDocument();
//Open report.
oReportClientDocument.open(reportName, 0);
//Get the report source
reportSource = oReportClientDocument.getReportSource();
//create the CrystalReportViewer object
CrystalReportViewer oCrystalReportViewer = new CrystalReportViewer();
//set the reportsource property of the viewer
oCrystalReportViewer.setReportSource(reportSource);
//set viewer attributes
oCrystalReportViewer.setOwnPage(true);
oCrystalReportViewer.setOwnForm(true);
//set the CrystalReportViewer print mode
oCrystalReportViewer.setPrintMode(CrPrintMode.ACTIVEX);
...
Avatar of habibb
habibb
Flag of Pakistan image

by using following code you can export report to excel for your web solutions.



CrystalDecisions.Shared.ExcelFormatOptions  objExcelOptions = new CrystalDecisions.Shared.ExcelFormatOptions();
                              objExcelOptions.ExcelUseConstantColumnWidth = true;
                                          
                              m_ReportDoc.ExportOptions.FormatOptions = objExcelOptions;    

                              MemoryStream objStream  = (MemoryStream)oReportClientDocument .ExportToStream(CrystalDecisions.Shared.ExportFormatType.ExcelRecord);
                              Response.Clear();
                              Response.ContentType="application/vnd.ms-excel";
                              Response.BinaryWrite(objStream.ToArray());
                              Response.End();
Avatar of craigyang
craigyang

ASKER

Do you have a solution using JSP?
>>> The export option of Excel doesn't show up on my web Crystal Report

This normally means that the export dll hasn't been installed on the server...

frodoman
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer