Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ERROR in reading Excel file USING CONOS ReportNet API

Status
Not open for further replies.

CognosHelp

Programmer
Jun 28, 2006
5
US
Hi ,
I am using ReportnetAPI to login into Cognos sever and get the PDF or XLS file . These files will be regenrayed based on input i give.I am getting PDF file without any error. BUt i am not getting XLS in proper format. I have given the short code here. Please could someone help me on this;

/////code to populate params


ReportServiceResponse rsr = null;
try {

rsr = oCrn.execute(reportPath,params,ro);

} catch (RemoteException e) {

}
try {

rsr = oCrn.getOutput(rsr.getPrimaryRequest());

} catch (RemoteException e) {
}
}

byte [] binaryOutput = Base64.decode(rsr.getOutputPages()[0]);
File tempFile = null;
try {

if ((xPath.equals("xxx_xls")) || (xPath.equals("yyy_xls"))){

tempFile = File.createTempFile("rep",".xls",new File(destDir));
}else{
tempFile = File.createTempFile("rep",".pdf",new File(destDir));
}

FileOutputStream fos = new FileOutputStream(tempFile);
fos.write(binaryOutput);
fos.close();
 
I am giving elaborated code..

RunOptionStringArray rosa = new RunOptionStringArray();
rosa.setName(RunOptionEnum.outputFormat);
if ((xPath.equals("xxx_xls")) || (xPath.equals("yyy_xls"))){
{
rosa.setValue(new String[] {"PDF"});
}else{
rosa.setValue(new String[] {"XLS"});
}

RunOption ro[] = new RunOption[2];
ro[0] = rosa;
ro[1] = saveOutput;


//// code to create params

ReportServiceResponse rsr = null;
try {

rsr = oCrn.execute(reportPath,params,ro);

} catch (RemoteException e) {

}
try {

rsr = oCrn.getOutput(rsr.getPrimaryRequest());

} catch (RemoteException e) {
}
}

byte [] binaryOutput = Base64.decode(rsr.getOutputPages()[0]);
File tempFile = null;
try {

if ((xPath.equals("xxx_xls")) || (xPath.equals("yyy_xls"))){

tempFile = File.createTempFile("rep",".xls",new File(destDir));
}else{
tempFile = File.createTempFile("rep",".pdf",new File(destDir));
}

FileOutputStream fos = new FileOutputStream(tempFile);
fos.write(binaryOutput);
fos.close();
 
Thanks for your response.

I have to get the format of Excel 2000 Single Sheet OR Excel 2000.

In that code if u try to give as below , i am getting error. Its working fine for PDF format.

rosa.setValue(new String[] {"Excel 2000 Single Sheet"});

OR

rosa.setValue(new String[] {"Excel 2000"});
 
And that error that you are getting is ...

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
I am getting the error , when i run the line

rsr = oCrn.execute(reportPath,params,ro);

Its saying "client Error"

Caused by: Client Error
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at com.cognos.developer.schemas.bibus._2.CognosReportNetBindingStub.execute(CognosReportNetBindingStub.java:4006)
at AutomatedProcesses.BusinessProcesses.GetReportNotifications.GetReportNotificationsJavaCode.finalCreateReport(GetReportNotificationsJavaCode.java:318)
... 13 more
 
Hi all,


With mentioning XLS is working. But i think the probelm is with decoding format. I am doing for pDF like below mentioned

byte [] binaryOutput = Base64.decode(rsr.getOutputPages()[0]);

Please anyone could tell me that how to reterive the output for Excel.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top