Page 1 of 1

table - row height

PostPosted: Tue Oct 05, 2010 3:33 pm
by sharu1484
Hello Jason,
I am able to alter the width of the table column but not able to set the height of the table row.
How to change the height of the row?

Regards,
Sharad

Re: table - rrow height

PostPosted: Tue Oct 05, 2010 5:04 pm
by jason
Hi Sharad

What is the WordML you were trying to create?

What code were you using to do it?

Re: table - row height

PostPosted: Tue Oct 05, 2010 5:52 pm
by sharu1484
Hello Jason,
Here is the code snippet which I have written for WordML and also to set the table width:
Code: Select all
File reportFile = new File(System.getProperty("user.dir"), "Draft Report.docx");
         WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
         .createPackage();   
Tbl jpegTable = TblFactory.createTable(0, 0, 8000);
jpegTable = setTableWidth(jpegTable, 8700);
Tr tableRow1 = objectFactory.createTr();
Tr tableRow2 = objectFactory.createTr();
jpegTable.getEGContentRowContent().add(tableRow1);
         jpegTable.getEGContentRowContent().add(tableRow2);

         wordMLPackage.getMainDocumentPart().addObject(jpegTable);


private static Tbl setTableWidth(Tbl tbl, long width){
      TblPr tblPr = objectFactory.createTblPr();
      TblWidth tblWidth = objectFactory.createTblWidth();
      tblWidth.setW(BigInteger.valueOf(width));
      tblWidth.setType("dxa"); // twips
      tblPr.setTblW(tblWidth);
      tbl.setTblPr(tblPr);
      return tbl;
   }



Hope this helps, let me know if you need more info.

Rgds,
Sharad

Re: table - row height

PostPosted: Tue Oct 05, 2010 8:31 pm
by jason
Umm, at a glance, your code doesn't even attempt to set the row height?

You need to work out what the appropriate XML is (easiest done in Word, then inspecting the result), and then insert that.

You'll find what you are after is trHeight. See http://www.documentinteropinitiative.or ... f820a.aspx