If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

How to read or import reports and its contents

Started by Galaxy, 20 Jul 2011 01:42:39 PM

Previous topic - Next topic

Galaxy


Hi All,

Have one question on cognos SDK.  I need to read  the report contents and save as a html file OR  need to import the report as a pdf file / htm file.

How to achieve this ?  please share your ideas.   and i am able to connect to the content store and able to list the reports

jdzurek

You can access the report specification content XML through the use of CMService Query method. This might help you out.

ex:

public void setReportSpecs(String ReportPath) throws Exception{
        String sReportSpec = null;
        PropEnum props[] = new PropEnum[]{PropEnum.searchPath, PropEnum.defaultName, PropEnum.specification};
        SearchPathMultipleObject spMulti = new SearchPathMultipleObject();
        spMulti.set_value(ReportPath);

        try {
            BaseClass[] repPth = cognosConnection.getCmService().query(spMulti, props, new Sort[]{}, new QueryOptions());
           
            // There should be only one report with the specified searchPath
            if (repPth != null && repPth.length > 0)
            {
                // extract the report spec
                sReportSpec = (((Report) repPth[0]).getSpecification().getValue());
                DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = builderFactory.newDocumentBuilder();
                InputStream is = new ByteArrayInputStream(sReportSpec.getBytes("UTF-8"));
                this.xmlDoc = builder.parse(is);
            }
            else
                this.xmlDoc = null;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }