on 08-11-2008 10:26 AM
Hi,
I am trying to create a sample report using JAVA SDK.
I slelect 4 "free cells" and pass 4 different strings to it.
I even slelect the font colour and size. When i run the class and try to view the report in Infoview, I only seeblank blocks without any data. Now if I edit the report from infoview, and save the changes, I am able to see the data.
My issue is, Why am I not able to see the data when I run the java code.
Please find teh code below.
package com;
import java.awt.Color;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.businessobjects.rebean.wi.BinaryView;
import com.businessobjects.rebean.wi.DataProvider;
import com.businessobjects.rebean.wi.DataProviders;
import com.businessobjects.rebean.wi.DataSource;
import com.businessobjects.rebean.wi.DataSourceObject;
import com.businessobjects.rebean.wi.DocumentInstance;
import com.businessobjects.rebean.wi.DocumentLocaleType;
import com.businessobjects.rebean.wi.FontImpl;
import com.businessobjects.rebean.wi.FreeCell;
import com.businessobjects.rebean.wi.HTMLView;
import com.businessobjects.rebean.wi.OutputFormatType;
import com.businessobjects.rebean.wi.PageHeaderFooter;
import com.businessobjects.rebean.wi.Query;
import com.businessobjects.rebean.wi.Recordset;
import com.businessobjects.rebean.wi.Report;
import com.businessobjects.rebean.wi.ReportBody;
import com.businessobjects.rebean.wi.ReportCell;
import com.businessobjects.rebean.wi.ReportContainer;
import com.businessobjects.rebean.wi.ReportElement;
import com.businessobjects.rebean.wi.ReportEngine;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.framework.ISessionMgr;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.plugin.CeKind;
public class Aug7th {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String CMS = "pundl8136:6400";
String userID = "srivas";
String password = "morcom123";
String auth = "secEnterprise";
List<String> entire =new ArrayList<String>();
List<String> country =new ArrayList<String>();
List<String> resort =new ArrayList<String>();
IEnterpriseSession enterpriseSession;
try
{
ISessionMgr mySessionMgr = CrystalEnterprise.getSessionMgr();
enterpriseSession = mySessionMgr.logon(userID, password, CMS,auth);
if (enterpriseSession != null)
{//Create and store useful objects for the session.
IInfoStore iStore = (IInfoStore)enterpriseSession.getService("InfoStore");
ReportEngine reportEngine = (ReportEngine)enterpriseSession.getService("WebiReportEngine");
IInfoObject infoView = null;
String str = "SELECT SI_ID, SI_NAME, SI_PARENTID FROM CI_INFOOBJECTS WHERE (SI_KIND = '"+CeKind.WEBI+"' OR SI_KIND='FullClient') " +
"AND SI_INSTANCE = 'false' AND SI_NAME='Structure Test_001_Java' ORDER BY SI_NAME ASC ";
//String str = "SELECT SI_ID, SI_NAME, SI_PARENTID FROM CI_INFOOBJECTS ORDER BY SI_NAME ASC ";
IInfoObjects objInfoObjectsWIDs = (IInfoObjects) iStore.query(str);
System.out.println(objInfoObjectsWIDs.size());
IInfoObject objInfoObjectWID = (IInfoObject) objInfoObjectsWIDs.get(0);
DocumentInstance doc = reportEngine.openDocument(objInfoObjectWID.getID());
DataProviders dps = doc.getDataProviders();
// Retrieve the 1st data provider
DataProvider dp = dps.getItem(0);
// Retrieve the universe objects
DataSource ds = dp.getDataSource ();
Query q = dp.getQuery();
Recordset rs = dp.getResult(0);
// 0: assume query has one flow
rs.first();
// Print the column types. They can be Integer, String,
// or Date.
for (int i = 0; i < rs.getColumnCount(); i++) {
Class c = rs.getColumnType(i);
StringBuffer sbt = new StringBuffer();
if ( c.equals(Integer.class) )
sbt.append("Integer");
if ( c.equals(String.class) )
sbt.append("String");
if ( c.equals(Date.class) )
sbt.append("Date");
sbt.append(";");
System.out.println(sbt.toString());
System.out.println(rs.getColumnCount());
}
while (!rs.isLast()) {
// column names
StringBuffer sbn = new StringBuffer();
StringBuffer sbd = new StringBuffer();
for (int j = 0; j < rs.getColumnCount(); j++) {
sbn.append( rs.getColumnName(j).toString() );
sbn.append(";");
}
System.out.println("sbn "+sbn.toString());
// data
for (int k= 0; k< rs.getColumnCount(); k++) {
sbd.append( rs.getCellObject(k).toString() );
sbd.append(";");
entire.add(rs.getCellObject(k).toString());
}
System.out.println("sbd "+sbd.toString());
rs.next();
}
System.out.println(entire.size());
for(int i=0;i<entire.size();i++){
country.add(entire.get(i));
i++;
System.out.println("entireList "+entire.get(i));
resort.add(entire.get(i));
}
DataSourceObject city = ds.getClasses().getChildByName("Country");
DataSourceObject resorts = ds.getClasses().getChildAt(1);
dp.runQuery();
ReportContainer report = doc.createReport("Resort");
PageHeaderFooter header = report.getPageHeader();
FreeCell headerCell = header.createFreeCell("Resort Report");
PageHeaderFooter footer = report.getPageFooter();
FreeCell footerCell = footer.createFreeCell("Report Ends");
ReportBody body = report.createReportBody();
for(int k=0;k<resort.size();k++){
FreeCell res=body.createFreeCell(resort.get(k));
res.getAttachTo();
res.setHeight(15d);
res.setWidth(30d);
Color c = new Color(255,255,255);
Color c1 = new Color(255,0,0);
FontImpl fnt = (FontImpl)res.getFont();
fnt.getDecoration().setTextColor(c1);
res.setFont(fnt);
//res.deleteAttachment();
//res.setAttachTo(body,VAnchorType.BOTTOM,HAnchorType.NONE);
}
doc.applyFormat();
doc.refresh();
final String l_docToken = doc.getStorageToken();
final DocumentInstance l_docToSave = reportEngine.getDocumentFromStorageToken(l_docToken);
doc.saveAs("mor31",835,null,null);
doc.closeDocument();
/*
str = "SELECT SI_ID, SI_NAME, SI_PARENTID FROM CI_INFOOBJECTS WHERE (SI_KIND = '"+CeKind.WEBI+"' OR SI_KIND='FullClient') " +
"AND SI_INSTANCE = 'false' AND SI_NAME='mor31' ORDER BY SI_NAME ASC ";
//String str = "SELECT SI_ID, SI_NAME, SI_PARENTID FROM CI_INFOOBJECTS ORDER BY SI_NAME ASC ";
objInfoObjectsWIDs = (IInfoObjects) iStore.query(str);
System.out.println(objInfoObjectsWIDs.size());
objInfoObjectWID = (IInfoObject) objInfoObjectsWIDs.get(0);
DocumentInstance doc1 = reportEngine.openDocument(objInfoObjectWID.getID());
String token = doc1.getStorageToken();
DocumentInstance doc2 = reportEngine.getDocumentFromStorageToken(token);
doc2.saveAs("123123", 835, null, null);
*/
// doc.refresh();
//doc.save();
}
enterpriseSession.logoff();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
post it here
/community [original link is broken]
good luck
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.