public TOC(CT_SdtBlock block) { this.block = block; CT_SdtPr sdtPr = block.AddNewSdtPr(); CT_DecimalNumber id = sdtPr.AddNewId(); id.val = ("4844945"); sdtPr.AddNewDocPartObj().AddNewDocPartGallery().val = ("Table of contents"); CT_SdtEndPr sdtEndPr = block.AddNewSdtEndPr(); CT_RPr rPr = sdtEndPr.AddNewRPr(); CT_Fonts fonts = rPr.AddNewRFonts(); fonts.asciiTheme = (ST_Theme.minorHAnsi); fonts.eastAsiaTheme = (ST_Theme.minorHAnsi); fonts.hAnsiTheme = (ST_Theme.minorHAnsi); fonts.cstheme = (ST_Theme.minorBidi); rPr.AddNewB().val = false; rPr.AddNewBCs().val = false; rPr.AddNewColor().val = ("auto"); rPr.AddNewSz().val = 24; rPr.AddNewSzCs().val = 24; CT_SdtContentBlock content = block.AddNewSdtContent(); CT_P p = content.AddNewP(); byte[] b = Encoding.Unicode.GetBytes("00EF7E24"); p.rsidR = b; p.rsidRDefault = b; p.AddNewPPr().AddNewPStyle().val = ("TOCHeading"); p.AddNewR().AddNewT().Value = ("Table of Contents"); }
public TOC(CT_SdtBlock block) { this.block = block; CT_SdtPr ctSdtPr = block.AddNewSdtPr(); ctSdtPr.AddNewId().val = "4844945"; ctSdtPr.AddNewDocPartObj().AddNewDocPartGallery().val = "Table of contents"; CT_RPr ctRpr = block.AddNewSdtEndPr().AddNewRPr(); CT_Fonts ctFonts = ctRpr.AddNewRFonts(); ctFonts.asciiTheme = ST_Theme.minorHAnsi; ctFonts.eastAsiaTheme = ST_Theme.minorHAnsi; ctFonts.hAnsiTheme = ST_Theme.minorHAnsi; ctFonts.cstheme = ST_Theme.minorBidi; ctRpr.AddNewB().val = ST_OnOff.off; ctRpr.AddNewBCs().val = ST_OnOff.off; ctRpr.AddNewColor().val = "auto"; ctRpr.AddNewSz().val = 24UL; ctRpr.AddNewSzCs().val = 24UL; CT_P ctP = block.AddNewSdtContent().AddNewP(); byte[] bytes = Encoding.Unicode.GetBytes("00EF7E24"); ctP.rsidR = bytes; ctP.rsidRDefault = bytes; ctP.AddNewPPr().AddNewPStyle().val = "TOCHeading"; ctP.AddNewR().AddNewT().Value = "Table of Contents"; }
/// <summary> /// 设置颜色 /// </summary> /// <param name="run"></param> /// <param name="colorType"></param> public static void SetRunColor(this XWPFRun run, ColorType colorType) { Tuple <string, string> temp = GetColor(colorType); CT_R r = run.GetCTR(); CT_RPr rpr = r.IsSetRPr() ? r.rPr : r.AddNewRPr(); CT_Color color = rpr.IsSetColor() ? rpr.color : rpr.AddNewColor(); color.val = temp.Item1; }
/** * Set text color. * @param rgbStr - the desired color, in the hex form "RRGGBB". */ public void SetColor(String rgbStr) { CT_RPr pr = run.IsSetRPr() ? run.rPr : run.AddNewRPr(); NPOI.OpenXmlFormats.Wordprocessing.CT_Color color = pr.IsSetColor() ? pr.color : pr.AddNewColor(); color.val = (rgbStr); }
public void SetColor(string rgbStr) { CT_RPr ctRpr = this.run.IsSetRPr() ? this.run.rPr : this.run.AddNewRPr(); (ctRpr.IsSetColor() ? ctRpr.color : ctRpr.AddNewColor()).val = rgbStr; }
/** * Set text color. * @param rgbStr - the desired color, in the hex form "RRGGBB". */ public void SetColor(String rgbStr) { CT_RPr pr = GetRunProperties(true); NPOI.OpenXmlFormats.Wordprocessing.CT_Color color = pr.IsSetColor() ? pr.color : pr.AddNewColor(); color.val = (rgbStr); }