XMultiServiceFactory xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xDocument);
XTextTable xTextTable = ( XTextTable ) UnoRuntime.queryInterface(
XTextTable.class, xMSF.createInstance( "com.sun.star.text.TextTable" ) );
xTextTable.initialize( 7, 2);
xTextDocument.getText().insertTextContent( xTextRange, xTextTable, false );
XPropertySet xPS = ( XPropertySet ) UnoRuntime.queryInterface(
XPropertySet.class, xTextTable );
XCell xCell;
char tab[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
for(int i=0 ; i < 7 ; ++i )
{
for(int j=0 ; j < 2 ; ++j )
{
xCell = xTextTable.getCellByName(""+tab[j]+(i+1));
XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, xCell);
xTextRange.setString((String) tableau[i][j]);
xPS = ( XPropertySet ) UnoRuntime.queryInterface(
XPropertySet.class, xCell );
xPS.setPropertyValue( "VertOrient", com.sun.star.text.VertOrientation.TOP );
}
}
Partager