Home » Archived » BIRT » Dynamic CrossTab Report Generation
Dynamic CrossTab Report Generation [message #259386] |
Wed, 24 October 2007 23:51  |
Eclipse User |
|
|
|
Originally posted by: ziaur.rahman.grameensolutions.com
Hi,
I need to generate CrossTab report programmatically using design engine
api. Can someone help me to give an example?
Zia
|
|
|
Re: Dynamic CrossTab Report Generation [message #365006 is a reply to message #259386] |
Thu, 04 September 2008 23:36   |
Eclipse User |
|
|
|
Hi,
Please see the following example code. First you should get cube handle and
then create a crosstab using the dimension, level and measure from cube. For
crosstab
1, Add bindings on crosstab
2, Create Views of crosstab and dimensionHandle, levelHandle... in the View
3, Create a dataitem refer to the bindings in crosstab and add them in the
crosstabcell.
// Get Cube from report design
CubeHandle cube = designHandle.findCube( "Data Cube" );
// Create Crosstab
ExtendedItemHandle extendHandle =
CrosstabExtendedItemFactory.createCrosstabReportItem(
designHandle.getRoot( ),
cube,
null );
designHandle.getBody( ).add( extendHandle );
CrosstabReportItemHandle crosstabItem = (CrosstabReportItemHandle)
CrosstabUtil
.getReportItem( extendHandle );
// Create CUSTOMER Dimension binding
ComputedColumn d_customer = StructureFactory.createComputedColumn( );
d_customer.setName( "CUSTOMERNUMBER" );
d_customer.setExpression( "dimension[\"Group\"][\"CUSTOMERNUMBER\"]" );
d_customer.setDataType( "Integer" );
// Create CREDITLIMIT Dimension binding
ComputedColumn M_CREDITLIMIT = StructureFactory.createComputedColumn( );
M_CREDITLIMIT.setName(
"CREDITLIMIT_Group1/COUNTRY_Group/CUSTOMERNUMBER" );
M_CREDITLIMIT.setExpression( "measure[\"CREDITLIMIT\"]" );
M_CREDITLIMIT.setDataType( "float" );
M_CREDITLIMIT.setAggregateFunction( "sum" );
M_CREDITLIMIT.setAggregateOn( "Group1/COUNTRY,Group/CUSTOMERNUMBER" );
// Add bindings to Crosstab
extendHandle.addColumnBinding( d_customer, true );
// Create Column View
CrosstabViewHandle columnView = crosstabItem
.addCrosstabView( ICrosstabConstants.COLUMN_AXIS_TYPE );
DimensionHandle group = cube.getDimension( "Group" );
DimensionViewHandle groupView = columnView.insertDimension( group, -1 );
LevelHandle groupHandle = designHandle.findLevel(
"Group/CUSTOMERNUMBER" );//$NON-NLS-1$
groupView.insertLevel( groupHandle, -1 );
// Create Measure View
MeasureHandle measureHandle = cube.getMeasure( "CREDITLIMIT" );
MeasureViewHandle measureView = crosstabItem.insertMeasure(
measureHandle, -1 );//$NON-NLS-1$
measureView.addHeader( );
LabelHandle label = designHandle.getElementFactory( ).newLabel(
"CREDITLIMIT" );
label.setText( "CREDITLIMIT" );
measureView.getHeader( ).addContent( label );
// Set the dataitem's resultset column
DataItemHandle customer = designHandle.getElementFactory( ).newDataItem(
"CUSTOMERNUMBER" );
customer.setResultSetColumn( d_customer.getName( ) );
// Add dataitem into group view
groupView.getLevel( 0 ).getCell( ).addContent( customer );
"Ziaur Rahman" <ziaur.rahman@grameensolutions.com> wrote in message
news:accc589f56b125328e150aaaa707155f$1@www.eclipse.org...
> Hi,
> I need to generate CrossTab report programmatically using design engine
> api. Can someone help me to give an example?
>
> Zia
|
|
| |
Re: Dynamic CrossTab Report Generation [message #720774 is a reply to message #367987] |
Wed, 31 August 2011 04:31   |
Eclipse User |
|
|
|
I have also a problem using the crosstab in the before factory of an report.
Iam using the Example of Jason for dynamically creating an crosstab from the bird exchange.
When i use it in the Viewer it does work, but when i run it from my rcp application
i get an error, that CrosstabExtendedItemFactory could not be found.
I tried to put org.eclipse.birt.report.item.crosstab.core and org.eclipse.birt.report.item.crosstab.ui
to my dependencies with no effect.
This is the report from jason:
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.17" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 2.3.2.r232_20090202 Build <2.3.2.v20090218-0730></property>
<property name="units">in</property>
<method name="beforeFactory"><![CDATA[importPackage( Packages.org.eclipse.birt.report.model.api );
importPackage( Packages.org.eclipse.birt.report.item.crosstab.core.util);
importPackage( Packages.org.eclipse.birt.report.item.crosstab.core.de);
importPackage( Packages.org.eclipse.birt.report.item.crosstab.core);
try{
reportDesignHandle = reportContext.getReportRunnable().designHandle.getDesignHandle();
elementFactory = reportDesignHandle.getElementFactory();
cubeHandle = reportDesignHandle.getCubes().get(0);
xtab = CrosstabExtendedItemFactory.createCrosstabReportItem(reportDesignHandle, cubeHandle, "MyCrosstab" );
reportDesignHandle.getBody().add(xtab);
reportItem = xtab.getReportItem( );
xtabHandle = reportItem;
dimensionX = cubeHandle.getDimension(params["RowDimension"].value);
dimensionY = cubeHandle.getDimension(params["ColumnDimension"].value);
levelX = dimensionX.getDefaultHierarchy().getLevel(0)
levelY = dimensionY.getDefaultHierarchy().getLevel(0)
//Insert X Dimension
dvh = xtabHandle.insertDimension(dimensionX, ICrosstabConstants.ROW_AXIS_TYPE, 0);
levelViewHandle =dvh.insertLevel(levelX, 0);
cellHandle = levelViewHandle.getCell( );
eii = xtabHandle.getModelHandle( );
bindingColumn = StructureFactory.newComputedColumn( eii, levelX.getName( ) );
bindingHandle = eii.addColumnBinding( bindingColumn,false );
bindingColumn.setDataType( levelX.getDataType( ) );
exp = "dimension['" + dimensionX.getName()+"']['"+levelX.getName()+"']";
bindingColumn.setExpression( exp);
dataHandle = elementFactory.newDataItem( levelX.getName( ) );
dataHandle.setResultSetColumn( bindingHandle.getName( ) );
cellHandle.addContent( dataHandle );
//Insert Y Dimension
dvh = xtabHandle.insertDimension(dimensionY, ICrosstabConstants.COLUMN_AXIS_TYPE, 0);
levelViewHandle =dvh.insertLevel(levelY, 0);
cellHandle = levelViewHandle.getCell( );
eii = xtabHandle.getModelHandle( );
bindingColumn = StructureFactory.newComputedColumn( eii, levelY.getName( ) );
bindingHandle = eii.addColumnBinding( bindingColumn,false );
bindingColumn.setDataType( levelY.getDataType( ) );
exp = "dimension['" + dimensionY.getName()+"']['"+levelY.getName()+"']";
bindingColumn.setExpression( exp);
dataHandle = elementFactory.newDataItem( levelY.getName( ) );
dataHandle.setResultSetColumn( bindingHandle.getName( ) );
cellHandle.addContent( dataHandle );
//Measures
measure = cubeHandle.getMeasure(params["Measure"].value);
mvh = xtabHandle.insertMeasure(measure, 0);
mvh.getCell().getContents().get(0).setProperty("style", "mydata");
mvh.addHeader( );
labelHandle = elementFactory.newLabel( null );
labelHandle.setText( measure.getName() );
mvh.getHeader( ).addContent( labelHandle );
//Note that styles are imported so they do not need to be applied
}catch(e){
//importPackage( Packages.java.io );
//out = new PrintWriter( new FileWriter( "c:/test7/xtabevents.txt", true ) );
//out.println(e);
//out.close();
}
]]></method>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<parameters>
<scalar-parameter name="ColumnDimension" id="37">
<property name="valueType">static</property>
<property name="dataType">string</property>
<property name="paramType">simple</property>
<property name="controlType">list-box</property>
<property name="mustMatch">true</property>
<property name="fixedOrder">true</property>
<property name="distinct">true</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
<list-property name="selectionList">
<structure>
<property name="value">Group</property>
<property name="label">Country</property>
</structure>
<structure>
<property name="value">Group1</property>
<property name="label">Product Line</property>
</structure>
<structure>
<property name="value">Group2</property>
<property name="label">Date</property>
</structure>
</list-property>
</scalar-parameter>
<scalar-parameter name="RowDimension" id="38">
<property name="valueType">static</property>
<property name="dataType">string</property>
<property name="paramType">simple</property>
<property name="controlType">list-box</property>
<property name="mustMatch">true</property>
<property name="fixedOrder">true</property>
<property name="distinct">true</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
<list-property name="selectionList">
<structure>
<property name="value">Group</property>
<property name="label">Country</property>
</structure>
<structure>
<property name="value">Group1</property>
<property name="label">Product Line</property>
</structure>
<structure>
<property name="value">Group2</property>
<property name="label">Date</property>
</structure>
</list-property>
</scalar-parameter>
<scalar-parameter name="Measure" id="39">
<property name="valueType">static</property>
<property name="dataType">string</property>
<property name="paramType">simple</property>
<property name="controlType">list-box</property>
<property name="mustMatch">true</property>
<property name="fixedOrder">true</property>
<property name="distinct">true</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
<list-property name="selectionList">
<structure>
<property name="value">SALES</property>
<property name="label">Sales</property>
</structure>
<structure>
<property name="value">PROFIT</property>
<property name="label">Profit</property>
</structure>
</list-property>
</scalar-parameter>
</parameters>
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Data Source" id="7">
<property name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver</property>
<property name="odaURL">jdbc:classicmodels:sampledb</property>
<property name="odaUser">ClassicModels</property>
<property name="OdaConnProfileName"></property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" name="Data Set" id="8">
<list-property name="columnHints">
<structure>
<property name="columnName">COUNTRY</property>
<property name="displayName">COUNTRY</property>
</structure>
<structure>
<property name="columnName">PRODUCTLINE</property>
<property name="displayName">PRODUCTLINE</property>
</structure>
<structure>
<property name="columnName">ORDERDATE</property>
<property name="displayName">ORDERDATE</property>
</structure>
<structure>
<property name="columnName">SALES</property>
<property name="displayName">SALES</property>
</structure>
<structure>
<property name="columnName">PROFIT</property>
<property name="displayName">PROFIT</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">COUNTRY</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">PRODUCTLINE</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">ORDERDATE</property>
<property name="dataType">date</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">SALES</property>
<property name="dataType">float</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">PROFIT</property>
<property name="dataType">float</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">COUNTRY</property>
<property name="nativeName">COUNTRY</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">PRODUCTLINE</property>
<property name="nativeName">PRODUCTLINE</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">ORDERDATE</property>
<property name="nativeName">ORDERDATE</property>
<property name="dataType">date</property>
<property name="nativeDataType">91</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">SALES</property>
<property name="nativeName">SALES</property>
<property name="dataType">float</property>
<property name="nativeDataType">8</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">PROFIT</property>
<property name="nativeName">PROFIT</property>
<property name="dataType">float</property>
<property name="nativeDataType">8</property>
</structure>
</list-property>
<property name="queryText">select c.country, p.productline, o.orderdate, sum(od.priceeach*od.quantityordered) as Sales, sum((od.priceeach-p.buyprice)*od.quantityordered) as Profit
from customers c, products p, orders o, orderdetails od
where o.ordernumber = od.ordernumber
and od.productcode = p.productcode
and o.customernumber = c.customernumber
group by c.country, p.productline, o.orderdate</property>
</oda-data-set>
</data-sets>
<cubes>
<tabular-cube name="Data Cube" id="9">
<property name="dimensions">
<tabular-dimension name="Group" id="14">
<property name="defaultHierarchy">NewTabularHierarchy</property>
<property name="hierarchies">
<tabular-hierarchy name="NewTabularHierarchy" id="15">
<property name="levels">
<tabular-level name="COUNTRY" id="16">
<property name="dataType">string</property>
<property name="columnName">COUNTRY</property>
</tabular-level>
</property>
</tabular-hierarchy>
</property>
</tabular-dimension>
<tabular-dimension name="Group1" id="17">
<property name="defaultHierarchy">NewTabularHierarchy1</property>
<property name="hierarchies">
<tabular-hierarchy name="NewTabularHierarchy1" id="18">
<property name="levels">
<tabular-level name="PRODUCTLINE" id="19">
<property name="dataType">string</property>
<property name="columnName">PRODUCTLINE</property>
</tabular-level>
</property>
</tabular-hierarchy>
</property>
</tabular-dimension>
<tabular-dimension name="Group2" id="20">
<property name="isTimeType">true</property>
<property name="defaultHierarchy">NewTabularHierarchy2</property>
<property name="hierarchies">
<tabular-hierarchy name="NewTabularHierarchy2" id="21">
<property name="levels">
<tabular-level name="year" id="22">
<property name="dataType">integer</property>
<property name="dateTimeLevelType">year</property>
<list-property name="attributes">
<structure>
<property name="name">DateTime</property>
<property name="dataType">date-time</property>
</structure>
</list-property>
<property name="columnName">ORDERDATE</property>
</tabular-level>
<tabular-level name="quarter" id="23">
<property name="dataType">integer</property>
<property name="dateTimeLevelType">quarter</property>
<list-property name="attributes">
<structure>
<property name="name">DateTime</property>
<property name="dataType">date-time</property>
</structure>
</list-property>
<property name="columnName">ORDERDATE</property>
</tabular-level>
<tabular-level name="month" id="24">
<property name="dataType">integer</property>
<property name="dateTimeLevelType">month</property>
<list-property name="attributes">
<structure>
<property name="name">DateTime</property>
<property name="dataType">date-time</property>
</structure>
</list-property>
<property name="columnName">ORDERDATE</property>
</tabular-level>
</property>
</tabular-hierarchy>
</property>
</tabular-dimension>
</property>
<property name="measureGroups">
<tabular-measure-group name="Summary Field" id="10">
<property name="measures">
<tabular-measure name="SALES" id="11">
<expression name="measureExpression">dataSetRow["SALES"]</expression>
<property name="dataType">float</property>
</tabular-measure>
</property>
</tabular-measure-group>
<tabular-measure-group name="Summary Field1" id="12">
<property name="measures">
<tabular-measure name="PROFIT" id="13">
<expression name="measureExpression">dataSetRow["PROFIT"]</expression>
<property name="dataType">float</property>
</tabular-measure>
</property>
</tabular-measure-group>
</property>
<property name="dataSet">Data Set</property>
</tabular-cube>
</cubes>
<styles>
<style name="report" id="4">
<property name="fontFamily">"Verdana"</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="table-header" id="40">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-footer" id="41">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-detail" id="42">
<property name="backgroundColor">#E6ECFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">x-small</property>
<property name="fontWeight">bold</property>
<property name="color">#000080</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-group-header-1" id="43">
<property name="backgroundColor">#809FFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-group-footer-1" id="44">
<property name="backgroundColor">#809FFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="special-header" id="45">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">medium</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="crosstab-detail" id="46">
<property name="backgroundColor">#E6ECFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">x-small</property>
<property name="fontWeight">bold</property>
<property name="color">#000080</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="crosstab-header" id="47">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="mydata" id="48">
<property name="color">#004080</property>
<structure name="numberFormat">
<property name="category">Currency</property>
<property name="pattern">$ #,##0.00</property>
</structure>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<property name="topMargin">0.25in</property>
<property name="leftMargin">0.25in</property>
<property name="bottomMargin">0.25in</property>
<property name="rightMargin">0.25in</property>
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
</report>
thanks for any help and time
|
|
|
Re: Dynamic CrossTab Report Generation [message #720932 is a reply to message #720774] |
Wed, 31 August 2011 09:54   |
Eclipse User |
|
|
|
Johannes,
Do you have all the birt plugins in your rcp app?
Jason
On 8/31/2011 4:31 AM, Johannes.Koshy wrote:
> I have also a problem using the crosstab in the before factory of an
> report.
> Iam using the Example of Jason for dynamically creating an crosstab from
> the bird exchange.
> When i use it in the Viewer it does work, but when i run it from my rcp
> application
> i get an error, that CrosstabExtendedItemFactory could not be found.
> I tried to put org.eclipse.birt.report.item.crosstab.core and
> org.eclipse.birt.report.item.crosstab.ui
> to my dependencies with no effect.
>
> This is the report from jason:
> <?xml version="1.0" encoding="UTF-8"?>
> <report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.17"
> id="1">
> <property name="createdBy">Eclipse BIRT Designer Version
> 2.3.2.r232_20090202 Build <2.3.2.v20090218-0730></property>
> <property name="units">in</property>
> <method name="beforeFactory"><![CDATA[importPackage(
> Packages.org.eclipse.birt.report.model.api );
> importPackage( Packages.org.eclipse.birt.report.item.crosstab.core.util);
> importPackage( Packages.org.eclipse.birt.report.item.crosstab.core.de);
> importPackage( Packages.org.eclipse.birt.report.item.crosstab.core);
>
> try{
>
> reportDesignHandle =
> reportContext.getReportRunnable().designHandle.getDesignHandle();
> elementFactory = reportDesignHandle.getElementFactory();
> cubeHandle = reportDesignHandle.getCubes().get(0);
>
>
> xtab =
> CrosstabExtendedItemFactory.createCrosstabReportItem(reportDesignHandle,
> cubeHandle, "MyCrosstab" );
> reportDesignHandle.getBody().add(xtab);
>
>
> reportItem = xtab.getReportItem( );
> xtabHandle = reportItem;
>
> dimensionX = cubeHandle.getDimension(params["RowDimension"].value);
> dimensionY = cubeHandle.getDimension(params["ColumnDimension"].value);
>
> levelX = dimensionX.getDefaultHierarchy().getLevel(0)
> levelY = dimensionY.getDefaultHierarchy().getLevel(0)
>
> //Insert X Dimension
> dvh = xtabHandle.insertDimension(dimensionX,
> ICrosstabConstants.ROW_AXIS_TYPE, 0);
> levelViewHandle =dvh.insertLevel(levelX, 0);
> cellHandle = levelViewHandle.getCell( );
> eii = xtabHandle.getModelHandle( );
>
> bindingColumn = StructureFactory.newComputedColumn( eii, levelX.getName(
> ) );
> bindingHandle = eii.addColumnBinding( bindingColumn,false );
> bindingColumn.setDataType( levelX.getDataType( ) );
> exp = "dimension['" + dimensionX.getName()+"']['"+levelX.getName()+"']";
> bindingColumn.setExpression( exp);
>
> dataHandle = elementFactory.newDataItem( levelX.getName( ) );
> dataHandle.setResultSetColumn( bindingHandle.getName( ) );
> cellHandle.addContent( dataHandle );
>
> //Insert Y Dimension
> dvh = xtabHandle.insertDimension(dimensionY,
> ICrosstabConstants.COLUMN_AXIS_TYPE, 0);
> levelViewHandle =dvh.insertLevel(levelY, 0);
> cellHandle = levelViewHandle.getCell( );
> eii = xtabHandle.getModelHandle( );
>
> bindingColumn = StructureFactory.newComputedColumn( eii, levelY.getName(
> ) );
> bindingHandle = eii.addColumnBinding( bindingColumn,false );
> bindingColumn.setDataType( levelY.getDataType( ) );
> exp = "dimension['" + dimensionY.getName()+"']['"+levelY.getName()+"']";
> bindingColumn.setExpression( exp);
>
> dataHandle = elementFactory.newDataItem( levelY.getName( ) );
> dataHandle.setResultSetColumn( bindingHandle.getName( ) );
> cellHandle.addContent( dataHandle );
>
>
>
> //Measures
> measure = cubeHandle.getMeasure(params["Measure"].value);
> mvh = xtabHandle.insertMeasure(measure, 0);
>
> mvh.getCell().getContents().get(0).setProperty("style", "mydata");
>
> mvh.addHeader( );
> labelHandle = elementFactory.newLabel( null );
> labelHandle.setText( measure.getName() );
> mvh.getHeader( ).addContent( labelHandle );
> //Note that styles are imported so they do not need to be applied
>
> }catch(e){
> //importPackage( Packages.java.io );
> //out = new PrintWriter( new FileWriter( "c:/test7/xtabevents.txt", true
> ) );
> //out.println(e);
> //out.close();
> }
>
> ]]></method>
> <property name="iconFile">/templates/blank_report.gif</property>
> <property name="bidiLayoutOrientation">ltr</property>
> <parameters>
> <scalar-parameter name="ColumnDimension" id="37">
> <property name="valueType">static</property>
> <property name="dataType">string</property>
> <property name="paramType">simple</property>
> <property name="controlType">list-box</property>
> <property name="mustMatch">true</property>
> <property name="fixedOrder">true</property>
> <property name="distinct">true</property>
> <structure name="format">
> <property name="category">Unformatted</property>
> </structure>
> <list-property name="selectionList">
> <structure>
> <property name="value">Group</property>
> <property name="label">Country</property>
> </structure>
> <structure>
> <property name="value">Group1</property>
> <property name="label">Product Line</property>
> </structure>
> <structure>
> <property name="value">Group2</property>
> <property name="label">Date</property>
> </structure>
> </list-property>
> </scalar-parameter>
> <scalar-parameter name="RowDimension" id="38">
> <property name="valueType">static</property>
> <property name="dataType">string</property>
> <property name="paramType">simple</property>
> <property name="controlType">list-box</property>
> <property name="mustMatch">true</property>
> <property name="fixedOrder">true</property>
> <property name="distinct">true</property>
> <structure name="format">
> <property name="category">Unformatted</property>
> </structure>
> <list-property name="selectionList">
> <structure>
> <property name="value">Group</property>
> <property name="label">Country</property>
> </structure>
> <structure>
> <property name="value">Group1</property>
> <property name="label">Product Line</property>
> </structure>
> <structure>
> <property name="value">Group2</property>
> <property name="label">Date</property>
> </structure>
> </list-property>
> </scalar-parameter>
> <scalar-parameter name="Measure" id="39">
> <property name="valueType">static</property>
> <property name="dataType">string</property>
> <property name="paramType">simple</property>
> <property name="controlType">list-box</property>
> <property name="mustMatch">true</property>
> <property name="fixedOrder">true</property>
> <property name="distinct">true</property>
> <structure name="format">
> <property name="category">Unformatted</property>
> </structure>
> <list-property name="selectionList">
> <structure>
> <property name="value">SALES</property>
> <property name="label">Sales</property>
> </structure>
> <structure>
> <property name="value">PROFIT</property>
> <property name="label">Profit</property>
> </structure>
> </list-property>
> </scalar-parameter>
> </parameters>
> <data-sources>
> <oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc"
> name="Data Source" id="7">
> <property
> name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver</property>
>
> <property name="odaURL">jdbc:classicmodels:sampledb</property>
> <property name="odaUser">ClassicModels</property>
> <property name="OdaConnProfileName"></property>
> </oda-data-source>
> </data-sources>
> <data-sets>
> <oda-data-set
> extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet"
> name="Data Set" id="8">
> <list-property name="columnHints">
> <structure>
> <property name="columnName">COUNTRY</property>
> <property name="displayName">COUNTRY</property>
> </structure>
> <structure>
> <property name="columnName">PRODUCTLINE</property>
> <property name="displayName">PRODUCTLINE</property>
> </structure>
> <structure>
> <property name="columnName">ORDERDATE</property>
> <property name="displayName">ORDERDATE</property>
> </structure>
> <structure>
> <property name="columnName">SALES</property>
> <property name="displayName">SALES</property>
> </structure>
> <structure>
> <property name="columnName">PROFIT</property>
> <property name="displayName">PROFIT</property>
> </structure>
> </list-property>
> <structure name="cachedMetaData">
> <list-property name="resultSet">
> <structure>
> <property name="position">1</property>
> <property name="name">COUNTRY</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">2</property>
> <property name="name">PRODUCTLINE</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">3</property>
> <property name="name">ORDERDATE</property>
> <property name="dataType">date</property>
> </structure>
> <structure>
> <property name="position">4</property>
> <property name="name">SALES</property>
> <property name="dataType">float</property>
> </structure>
> <structure>
> <property name="position">5</property>
> <property name="name">PROFIT</property>
> <property name="dataType">float</property>
> </structure>
> </list-property>
> </structure>
> <property name="dataSource">Data Source</property>
> <list-property name="resultSet">
> <structure>
> <property name="position">1</property>
> <property name="name">COUNTRY</property>
> <property name="nativeName">COUNTRY</property>
> <property name="dataType">string</property>
> <property name="nativeDataType">12</property>
> </structure>
> <structure>
> <property name="position">2</property>
> <property name="name">PRODUCTLINE</property>
> <property name="nativeName">PRODUCTLINE</property>
> <property name="dataType">string</property>
> <property name="nativeDataType">12</property>
> </structure>
> <structure>
> <property name="position">3</property>
> <property name="name">ORDERDATE</property>
> <property name="nativeName">ORDERDATE</property>
> <property name="dataType">date</property>
> <property name="nativeDataType">91</property>
> </structure>
> <structure>
> <property name="position">4</property>
> <property name="name">SALES</property>
> <property name="nativeName">SALES</property>
> <property name="dataType">float</property>
> <property name="nativeDataType">8</property>
> </structure>
> <structure>
> <property name="position">5</property>
> <property name="name">PROFIT</property>
> <property name="nativeName">PROFIT</property>
> <property name="dataType">float</property>
> <property name="nativeDataType">8</property>
> </structure>
> </list-property>
> <property name="queryText">select c.country, p.productline, o.orderdate,
> sum(od.priceeach*od.quantityordered) as Sales,
> sum((od.priceeach-p.buyprice)*od.quantityordered) as Profit from
> customers c, products p, orders o, orderdetails od
> where o.ordernumber = od.ordernumber
> and od.productcode = p.productcode
> and o.customernumber = c.customernumber
> group by c.country, p.productline, o.orderdate</property>
> </oda-data-set>
> </data-sets>
> <cubes>
> <tabular-cube name="Data Cube" id="9">
> <property name="dimensions">
> <tabular-dimension name="Group" id="14">
> <property name="defaultHierarchy">NewTabularHierarchy</property>
> <property name="hierarchies">
> <tabular-hierarchy name="NewTabularHierarchy" id="15">
> <property name="levels">
> <tabular-level name="COUNTRY" id="16">
> <property name="dataType">string</property>
> <property name="columnName">COUNTRY</property>
> </tabular-level>
> </property>
> </tabular-hierarchy>
> </property>
> </tabular-dimension>
> <tabular-dimension name="Group1" id="17">
> <property name="defaultHierarchy">NewTabularHierarchy1</property>
> <property name="hierarchies">
> <tabular-hierarchy name="NewTabularHierarchy1" id="18">
> <property name="levels">
> <tabular-level name="PRODUCTLINE" id="19">
> <property name="dataType">string</property>
> <property name="columnName">PRODUCTLINE</property>
> </tabular-level>
> </property>
> </tabular-hierarchy>
> </property>
> </tabular-dimension>
> <tabular-dimension name="Group2" id="20">
> <property name="isTimeType">true</property>
> <property name="defaultHierarchy">NewTabularHierarchy2</property>
> <property name="hierarchies">
> <tabular-hierarchy name="NewTabularHierarchy2" id="21">
> <property name="levels">
> <tabular-level name="year" id="22">
> <property name="dataType">integer</property>
> <property name="dateTimeLevelType">year</property>
> <list-property name="attributes">
> <structure>
> <property name="name">DateTime</property>
> <property name="dataType">date-time</property>
> </structure>
> </list-property>
> <property name="columnName">ORDERDATE</property>
> </tabular-level>
> <tabular-level name="quarter" id="23">
> <property name="dataType">integer</property>
> <property name="dateTimeLevelType">quarter</property>
> <list-property name="attributes">
> <structure>
> <property name="name">DateTime</property>
> <property name="dataType">date-time</property>
> </structure>
> </list-property>
> <property name="columnName">ORDERDATE</property>
> </tabular-level>
> <tabular-level name="month" id="24">
> <property name="dataType">integer</property>
> <property name="dateTimeLevelType">month</property>
> <list-property name="attributes">
> <structure>
> <property name="name">DateTime</property>
> <property name="dataType">date-time</property>
> </structure>
> </list-property>
> <property name="columnName">ORDERDATE</property>
> </tabular-level>
> </property>
> </tabular-hierarchy>
> </property>
> </tabular-dimension>
> </property>
> <property name="measureGroups">
> <tabular-measure-group name="Summary Field" id="10">
> <property name="measures">
> <tabular-measure name="SALES" id="11">
> <expression name="measureExpression">dataSetRow["SALES"]</expression>
> <property name="dataType">float</property>
> </tabular-measure>
> </property>
> </tabular-measure-group>
> <tabular-measure-group name="Summary Field1" id="12">
> <property name="measures">
> <tabular-measure name="PROFIT" id="13">
> <expression name="measureExpression">dataSetRow["PROFIT"]</expression>
> <property name="dataType">float</property>
> </tabular-measure>
> </property>
> </tabular-measure-group>
> </property>
> <property name="dataSet">Data Set</property>
> </tabular-cube>
> </cubes>
> <styles>
> <style name="report" id="4">
> <property name="fontFamily">"Verdana"</property>
> <property name="fontSize">10pt</property>
> </style>
> <style name="crosstab-cell" id="5">
> <property name="borderBottomColor">#CCCCCC</property>
> <property name="borderBottomStyle">solid</property>
> <property name="borderBottomWidth">1pt</property>
> <property name="borderLeftColor">#CCCCCC</property>
> <property name="borderLeftStyle">solid</property>
> <property name="borderLeftWidth">1pt</property>
> <property name="borderRightColor">#CCCCCC</property>
> <property name="borderRightStyle">solid</property>
> <property name="borderRightWidth">1pt</property>
> <property name="borderTopColor">#CCCCCC</property>
> <property name="borderTopStyle">solid</property>
> <property name="borderTopWidth">1pt</property>
> </style>
> <style name="crosstab" id="6">
> <property name="borderBottomColor">#CCCCCC</property>
> <property name="borderBottomStyle">solid</property>
> <property name="borderBottomWidth">1pt</property>
> <property name="borderLeftColor">#CCCCCC</property>
> <property name="borderLeftStyle">solid</property>
> <property name="borderLeftWidth">1pt</property>
> <property name="borderRightColor">#CCCCCC</property>
> <property name="borderRightStyle">solid</property>
> <property name="borderRightWidth">1pt</property>
> <property name="borderTopColor">#CCCCCC</property>
> <property name="borderTopStyle">solid</property>
> <property name="borderTopWidth">1pt</property>
> </style>
> <style name="table-header" id="40">
> <property name="backgroundColor">#6078BF</property>
> <property name="fontFamily">"Arial"</property>
> <property name="fontSize">small</property>
> <property name="fontWeight">bold</property>
> <property name="color">#FFFFFF</property>
> <property name="paddingTop">0px</property>
> <property name="paddingLeft">0px</property>
> <property name="paddingBottom">0px</property>
> <property name="paddingRight">0px</property>
> </style>
> <style name="table-footer" id="41">
> <property name="backgroundColor">#6078BF</property>
> <property name="fontFamily">"Arial"</property>
> <property name="fontSize">small</property>
> <property name="fontWeight">bold</property>
> <property name="color">#FFFFFF</property>
> <property name="paddingTop">0px</property>
> <property name="paddingLeft">0px</property>
> <property name="paddingBottom">0px</property>
> <property name="paddingRight">0px</property>
> </style>
> <style name="table-detail" id="42">
> <property name="backgroundColor">#E6ECFF</property>
> <property name="fontFamily">"Arial"</property>
> <property name="fontSize">x-small</property>
> <property name="fontWeight">bold</property>
> <property name="color">#000080</property>
> <property name="paddingTop">0px</property>
> <property name="paddingLeft">0px</property>
> <property name="paddingBottom">0px</property>
> <property name="paddingRight">0px</property>
> </style>
> <style name="table-group-header-1" id="43">
> <property name="backgroundColor">#809FFF</property>
> <property name="fontFamily">"Arial"</property>
> <property name="fontSize">small</property>
> <property name="fontWeight">bold</property>
> <property name="color">#FFFFFF</property>
> <property name="paddingTop">0px</property>
> <property name="paddingLeft">0px</property>
> <property name="paddingBottom">0px</property>
> <property name="paddingRight">0px</property>
> </style>
> <style name="table-group-footer-1" id="44">
> <property name="backgroundColor">#809FFF</property>
> <property name="fontFamily">"Arial"</property>
> <property name="fontSize">small</property>
> <property name="fontWeight">bold</property>
> <property name="color">#FFFFFF</property>
> <property name="paddingTop">0px</property>
> <property name="paddingLeft">0px</property>
> <property name="paddingBottom">0px</property>
> <property name="paddingRight">0px</property>
> </style>
> <style name="special-header" id="45">
> <property name="backgroundColor">#6078BF</property>
> <property name="fontFamily">"Arial"</property>
> <property name="fontSize">medium</property>
> <property name="fontWeight">bold</property>
> <property name="color">#FFFFFF</property>
> <property name="paddingTop">0px</property>
> <property name="paddingLeft">0px</property>
> <property name="paddingBottom">0px</property>
> <property name="paddingRight">0px</property>
> </style>
> <style name="crosstab-detail" id="46">
> <property name="backgroundColor">#E6ECFF</property>
> <property name="fontFamily">"Arial"</property>
> <property name="fontSize">x-small</property>
> <property name="fontWeight">bold</property>
> <property name="color">#000080</property>
> <property name="paddingTop">0px</property>
> <property name="paddingLeft">0px</property>
> <property name="paddingBottom">0px</property>
> <property name="paddingRight">0px</property>
> </style>
> <style name="crosstab-header" id="47">
> <property name="backgroundColor">#6078BF</property>
> <property name="fontFamily">"Arial"</property>
> <property name="fontSize">small</property>
> <property name="fontWeight">bold</property>
> <property name="color">#FFFFFF</property>
> <property name="paddingTop">0px</property>
> <property name="paddingLeft">0px</property>
> <property name="paddingBottom">0px</property>
> <property name="paddingRight">0px</property>
> </style>
> <style name="mydata" id="48">
> <property name="color">#004080</property>
> <structure name="numberFormat">
> <property name="category">Currency</property>
> <property name="pattern">$ #,##0.00</property>
> </structure>
> </style>
> </styles>
> <page-setup>
> <simple-master-page name="Simple MasterPage" id="2">
> <property name="topMargin">0.25in</property>
> <property name="leftMargin">0.25in</property>
> <property name="bottomMargin">0.25in</property>
> <property name="rightMargin">0.25in</property>
> <page-footer>
> <text id="3">
> <property name="contentType">html</property>
> <text-property name="content"><![CDATA[<value-of>new
> Date()</value-of>]]></text-property>
> </text>
> </page-footer>
> </simple-master-page>
> </page-setup>
> </report>
>
> thanks for any help and time
|
|
| | | |
Goto Forum:
Current Time: Sun May 11 20:47:33 EDT 2025
Powered by FUDForum. Page generated in 0.11418 seconds
|