How to create table in impress

Hi,

I am trying to create a table on new slide, below is sample code I am using

Object drawShape = xDrawFactory.createInstance("com.sun.star.drawing.TableShape");
	
    XShape xDrawShape = (XShape)UnoRuntime.queryInterface(XShape.class, drawShape);
xDrawShape.setPosition(new Point(xoffset,150*72));
xDrawShape.setSize(new Size(tblWidth,200*72));
	
xDrawPageNew.add(xDrawShape);
XPropertySet xPropertyset = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xDrawShape );
XTable xTable = (XTable) UnoRuntime.queryInterface(XTable.class, xPropertyset.getPropertyValue( "Model" ));

	
xTable.getRows().insertByIndex(0, rSlideTable.getRows());
xTable.getColumns().insertByIndex(0, rSlideTable.getCols());
    // stuff data in table
for(Iterator<ReportSlideTableCell> iter= rSlideTable.getCells().iterator() ; iter.hasNext();)
{
	ReportSlideTableCell cell = iter.next();
	XCellRange xCellrange = (XCellRange) UnoRuntime.queryInterface( XCellRange.class, xTable );

	XCell xCell = xCellrange.getCellByPosition( cell.getRow()-1 , cell.getCol()-1 );

	XText xText = (XText) UnoRuntime.queryInterface( XText.class, xCell );
	xText.setString( cell.getText());			
	XTextCursor xTextCursor =xText.createTextCursor();
	XPropertySet xCursorProps = UnoRuntime.queryInterface(
	            XPropertySet.class, xTextCursor);					
	 xCursorProps.setPropertyValue("CharHeight",      new Float(11));

    }

I am not getting rows with proper height and columns with good width. The text flows vertically. Has anybody created a table on slide.

Thanks,
Ishwar

I just changed the order, adding the table to DrawPage and then setting the position and size, below code worked fine:

private void AddTable(
             XDrawPage xDrawPageNew,
             ReportSlideTable rSlideTable,
             ReportSlide slide,
             int tblWidth,
             int xoffset, 
             int tblCnt) throws Exception
{
	Object drawShape = xDrawFactory.createInstance("com.sun.star.drawing.TableShape");
            XShape xDrawShape = (XShape)UnoRuntime.queryInterface(XShape.class, drawShape);
	// First add the table
	xDrawPageNew.add(xDrawShape);
            // Get the table from model
	XPropertySet xPropertyset = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xDrawShape );
	XTable xTable = (XTable) UnoRuntime.queryInterface(
                         XTable.class, xPropertyset.getPropertyValue( "Model"));
            // Set rows and columns
	xTable.getRows().insertByIndex(0, rSlideTable.getRows());
	xTable.getColumns().insertByIndex(0, rSlideTable.getCols());
	
            // Set postion and size
	xDrawShape.setPosition(new Point(xoffset,3000));
	xDrawShape.setSize(new Size(tblWidth,10000));
	
     }