这仅仅是保证了再报表的query里拉出了这个对象不能保证在报表层面也使用了这个对象,在下一篇中也是同理,检索的对象名称为“Domestic / International”
<%@page import="java.io.FileOutputStream"%><%@ page language="java" errorPage="err_page.jsp"%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.List" %>
<%@ page import="java.io.*" %>
<%@ page import="jxl.Workbook" %>
<%@ page import="jxl.write.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.lang.Iterable" %>
<%@ page import="com.crystaldecisions.sdk.exception.SDKException" %>
<%@ page import="com.crystaldecisions.sdk.framework.CrystalEnterprise" %>
<%@ page import="com.crystaldecisions.sdk.framework.IEnterpriseSession" %>
<%@ page import="com.crystaldecisions.sdk.framework.ISessionMgr" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IEvents" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObject" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObjects" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoStore" %>
<%@ page import="com.crystaldecisions.sdk.plugin.desktop.event.IEvent" %>
<%@ page import="com.crystaldecisions.sdk.properties.IProperties" %>
<%@ page import="com.businessobjects.sdk.plugin.desktop.webi.IWebi" %>
<%@ page import="com.crystaldecisions.sdk.plugin.desktop.report.IReport" %>
<%@ page import="com.businessobjects.rebean.wi.*" %>
<%
IEnterpriseSession enterpriseSession=null ;
OutputStream os=null;
WritableWorkbook workbook=null;
try
{
// IEnterpriseSession enterpriseSession = LoginAndGetSession.getSession();
//String S_USER=request.getParameter("user").trim();
//String S_PASS=request.getParameter("pwd").trim();
//String startDate=request.getParameter("startDate").trim();
//String endDate=request.getParameter("endDate").trim();
//String S_HOST="@PPECLUSTER";
//String S_SECURITY="secEnterpris";
//System.out.println(S_USER);
//System.out.println(S_PASS);
//System.out.println(startDate);
//System.out.println(endDate);
//System.out.println(S_HOST);
//System.out.println(S_SECURITY);
ISessionMgr iSessionMgr = CrystalEnterprise.getSessionMgr();
System.out.println("start to log in");
enterpriseSession=iSessionMgr.logon("admincmc", "cmc2009", "*********", "secEnterprise");
// DocumentInstance doc;
ReportEngine objReportEngine=null;
try{
objReportEngine = (ReportEngine)enterpriseSession.getService("","WebiReportEngine"); ;
}catch(Exception e){
objReportEngine = (ReportEngine)enterpriseSession.getService("ReportEngine"); ;
}
System.out.println("start to log in2");
{
//test
}
IInfoStore infostore=(IInfoStore)enterpriseSession.getService("InfoStore");//2012.12.01.00.00.00
//get total of instance
IInfoObjects allReportcounts= infostore.query("SELECT count( SI_ID) FROM CI_INFOOBJECTS WHERE SI_KIND in('WEBI')AND SI_INSTANCE=0 and SI_CREATION_TIME>='2013.05.01.00.00.00'" );
IInfoObject allRportcount=(IInfoObject)allReportcounts.get(0);
//System.out.print("The total of instance is: "+allReports.size());
IProperties counts=(IProperties)allRportcount.properties().getProperties("SI_AGGREGATE_COUNT");
int IDCount=counts.getInt("SI_ID");
System.out.print("The total of instance is: "+IDCount);
int k=IDCount;
IInfoObjects allReports= infostore.query("SELECT top "+k+" * FROM CI_INFOOBJECTS WHERE SI_KIND in('Webi') and SI_INSTANCE=0 and SI_CREATION_TIME>='2013.05.01.00.00.00'"
);
String targetfile = "D:\\reportwithLOB1.xls";
File f=new File(targetfile);
if(f.exists())f.delete();
os=new FileOutputStream(targetfile);
workbook = Workbook.createWorkbook(os);
WritableSheet sheet = workbook.createSheet("Hongrao",0);
int row=0;
egencia:
for (int i=0;i<k;i++)
{
try{
IWebi a=(IWebi)allReports.get(i);
String path="";
String docName="";
String createdate="as";
String lastdate="as";
SimpleDateFormat sdf = new SimpleDateFormat( " yyyy-MM-dd HH:mm:ss " );
{
IInfoObject reportFolder = a.getParent();
docName=a.getTitle();
createdate=sdf.format( a.properties().getDate("SI_CREATION_TIME"));
lastdate=sdf.format( a.properties().getDate("SI_UPDATE_TS"));
// System.out.print(a.getTitle()+"\n");
if (a.getParentID() == 0)
path="Public Folders";
else
{ try{
while (1 > 0)
{
path = reportFolder.getTitle() + "/" + path;
// System.out.print(" Report path "+reportFolder.getTitle());
if (reportFolder.getParentID() == 0)
{path = "Public Folders"+ "/" + path;
// System.out.print(path+"\n");
break;
}
else
{
reportFolder = reportFolder.getParent();
//System.out.print(reportFolder);
}
}
}catch(Exception es){}
}
}
if(path.toLowerCase().indexOf("egencia")<0) continue;
{ DocumentInstance doc=null;
int hasit=0;
try{
doc= objReportEngine.openDocument(a.getID());
DataProviders dps = doc.getDataProviders();
int dpc=dps.getCount();
ends:
for(int j=0;j<dpc;j++)
{ DataProvider dp=dps.getItem(j);
Query q= dp.getQuery();
int qs=q.getResultObjectCount();
for(int jj=0;jj<qs;jj++)
{
DataSourceObject dso=q.getResultObject(jj);
String objname=dso.getName() ;
//
if(objname.equalsIgnoreCase("Domestic / International")) {
hasit=1;
break ends;
}
}
}
}catch(Exception es){out.println(a.getID()+":"+es.getMessage());}
finally{
doc.closeDocument();
}
if(hasit==0)continue egencia;
}
Label labelcon1=new Label(0,row,path);
Label labelcon2=new Label(1,row,docName);
Label labelcon3=new Label(2,row,createdate);
Label labelcon4=new Label(3,row,lastdate);
sheet.addCell(labelcon1);
sheet.addCell(labelcon2);
sheet.addCell(labelcon3);
sheet.addCell(labelcon4);
row+=1;
}catch(Exception eh){}
}
workbook.write();
workbook.close();
os.close();
out.print("sucess!");
}
catch(SDKException sdk){
workbook.close();
os.close();
out.print(sdk.getMessage());}
finally{
enterpriseSession.logoff();
}
%>