I've been looking for a XWPF styled table example, and found very little, I got the example Simple Table working, and found a styled Table example from POI, but calling, <tcpr.tcPrChange = new CT_TcPrChange();> whether, I make any additional calls to the tcpr object or not (<tcpr.AddNewShd().fill = "A7BFDE";>), causes the Table to render BADLY (WHOLE CELL IS BLACK). I would like to change the fill color:
tcpr.tcPrChange = new CT_TcPrChange();
tcpr.AddNewShd().fill = "A7BFDE";
The following is a summary of my success and failures:
XWPF Success:
* Create Paragraphs
* Set Font-Family
* Set Font-Size
* Set Font-Bold
* Set Text
* Set Run-Color
* Create Table
* Access Table-Cell-Paragraph
* Create Runs in Table-Cells
* SetInsideVBorder & SetInsideHBorder
XWPF Fail:
* AddPicture
* Set Table-Width
* Set Table-Column-Width
* Set Table-Row-Height
* Set Table-Cell-Background-Color
* Set Table-SetOutsideVBorder & Table-SetOutsideHBorder
* Set Page-Header/Footer
* Set Page-Orientation-Landscape (maybe not event supported in POI yet?)
Are any or all of these expected to work at this time?
If so, where can I find example code for each?
Thanks
Comments: ** Comment from web user: mg_bkm **
Hi, I'm trying NPOI for a similar task, using 2.1 and:
* AddPicture works
* for Page Orientation one could swap w and h, it works:
>> NPOI.OpenXmlFormats.Wordprocessing.CT_SectPr bodyProps = internalDoc.Document.body.sectPr;
>> bodyProps.pgSz.w = 16838;
>> bodyProps.pgSz.h = 11906;
But sadly, I found no solution yet for:
* Set Table-Cell-Background-Color
* Set Table-SetOutsideVBorder & Table-SetOutsideHBorder
* Set Page-Header/Footer
For cell background, going this way at least gives the right colors, but table is still broken with no text showing up:
>> if(!cell.GetCTTc().IsSetTcPr()) cell.GetCTTc().AddNewTcPr();
>> if(!cell.GetCTTc().tcPr.IsSetShd()) cell.GetCTTc().tcPr.AddNewShd();
>> NPOI.OpenXmlFormats.Wordprocessing.CT_Shd cellShd = cell.GetCTTc().tcPr.shd;
>> cellShd.val = NPOI.OpenXmlFormats.Wordprocessing.ST_Shd.solid;
>> cellShd.color = cellColor;
Haven't played with table/cell width/height yet.