Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Problem with report format
KavithaD
Hi,
I am having 4 radion buttons like pdf,doc,xls and html
On select of pdf and html I am able to generate report but on select of doc
I am able to generate report while opening doc i am getting following error
The document ****.doc cannot be opened because there are problems with the contents
and on select of xls I am getting following error
The file you are trying to open,xx.xls,is in a different format than specified by the file extension.verify that the file is not corrupted and
is from a trusted source before opening the file.
Could any one help me?
Thanks & Regards
Kavitha
Find more posts tagged with
Comments
mwilliams
Hi Kavitha,
I have not seen an error like this for the DOC output before, but I'm pretty sure I've seen the XLS warning. Do you get this warning in XLS every time you export to XLS or just with this report?
KavithaD
Hi mwilliams,
I am getting this error every time when i run the report.Is there any solution for this?I am generating report through birt API.
This is my code::
public String displayReport() {
logger.entering("execute");
String reportFormat = (String) sessionMap.get("reportFormat");
String notificationName = (String)sessionMap.get("reportName");
System.out.println("in report action:Format:" + reportFormat);
if (null == reportFormat) {
reportFormat = "pdf";
}
ServletContext sc = request.getSession().getServletContext();
try {
IReportEngine birtReportEngine = ReportEngineHelper
.getBirtEngine(sc);
IReportRunnable reportRunnable = birtReportEngine
.openReportDesign(sc.getRealPath("/resources")+"/reports/format_report.rptdesign");
ReportDesignHandle reportDesignHandle = (ReportDesignHandle) reportRunnable
.getDesignHandle();
// create task to run and render report
IRunAndRenderTask task = birtReportEngine
.createRunAndRenderTask(reportRunnable);
task.getAppContext().put(
EngineConstants.APPCONTEXT_CLASSLOADER_KEY,
ReportAction.class.getClassLoader());
task.setRenderOption(setReportFormat(reportFormat, "notificationName", response));
// run report
task.run();
task.close();
// ReportEngineHelper.destroyBirtEngine();
} catch (Exception e) {
}
logger.exiting("execute");
result = null;
return null;
}
private IRenderOption setReportFormat(String reportFormat,String fileName,
HttpServletResponse response) throws Exception {
IRenderOption renderOption = null;
if (reportFormat.equalsIgnoreCase("pdf")) {
response.setContentType("application/pdf");
response.setHeader("Content-Disposition","attachment; filename="+fileName+".pdf");
renderOption = new PDFRenderOption();
} else if (reportFormat.equalsIgnoreCase("xls")) {
response.setContentType("application/ms-excel");
response.setHeader("Content-Disposition",
"attachment; filename="+fileName+".xls");
renderOption = new EXCELRenderOption();
} else if (reportFormat.equalsIgnoreCase("html")) {
response.setContentType("text/html");
response.setHeader("Content-Disposition",
"attachment; filename="+fileName+".htm");
renderOption = new HTMLRenderOption();
} else if (reportFormat.equalsIgnoreCase("doc")) {
response.setContentType("application/msword");
response.setHeader("Content-Disposition",
"attachment; filename="+fileName+".doc");
renderOption = new PDFRenderOption();
}
renderOption.setOutputFormat(reportFormat);
// options.setOutputFormat("xls");
// options.setOutputFileName("output/resample/customers.xls");
renderOption.setOutputStream(response.getOutputStream());
return renderOption;
}
mwilliams
Kavitha,
What version of BIRT are you using? And what version of Microsoft Office are you using?
KavithaD
Hi mwilliams,
I could able to solve the problem.response was adding extra elements other than xml.
Thanks & regards
Kavitha
mwilliams
Kavitha,
Glad you were able to find a solution. Good luck!