Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

New Post: XWPFTable: how to set column width and cell borders?

$
0
0
Hello,
I have just begun creating docx with XWPFDocument. Could you please advice if my approach is proper, assuming that I would like to create a table with 3 columns, first narrow, second and third wider:
XWPFTable t0 = doc.CreateTable( 3, 3 );
t0.Width = 5000;

t0.GetRow( 0 ).GetCell( 0 ).SetText( "A" );
t0.GetRow( 0 ).GetCell( 1 ).SetText( "B" );
t0.GetRow( 0 ).GetCell( 2 ).SetText( "C" );

t0.GetRow( 1 ).GetCell( 0 ).SetText( "X" );
t0.GetRow( 1 ).GetCell( 1 ).SetText( "Name 1, Name 2, Name 3, Name 4" );
t0.GetRow( 1 ).GetCell( 2 ).SetText( "Name 1, Name 2, Name 3, Name 4" );

t0.SetColumnWidth( 0, 1000 );
t0.SetColumnWidth( 1, 2000 );
t0.SetColumnWidth( 2, 2000 );
Beside of it I would like to leave only horizontal lines (top, bottom and innern) for the table.
I know how to modify presence of cell borders for a spreadsheet but not for the Word docx table. Any help if I may please?

Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>