Beispiel #1
0
        public void SetColBandSize(int size)
        {
            CT_TblPr         tblPr   = GetTrPr();
            CT_DecimalNumber colSize = tblPr.IsSetTblStyleColBandSize() ? tblPr.tblStyleColBandSize : tblPr.AddNewTblStyleColBandSize();

            colSize.val = size.ToString();
        }
Beispiel #2
0
        private void CreateEmptyTable(CT_Tbl table)
        {
            // MINIMUM ELEMENTS FOR A TABLE
            table.AddNewTr().AddNewTc().AddNewP();

            CT_TblPr tblpro = table.AddNewTblPr();

            if (!tblpro.IsSetTblW())
            {
                tblpro.AddNewTblW().w = "0";
            }
            tblpro.tblW.type = (ST_TblWidth.auto);

            // layout
            // tblpro.AddNewTblLayout().Type=(STTblLayoutType.AUTOFIT);

            // borders
            CT_TblBorders borders = tblpro.AddNewTblBorders();

            borders.AddNewBottom().val  = (ST_Border.single);
            borders.AddNewInsideH().val = (ST_Border.single);
            borders.AddNewInsideV().val = (ST_Border.single);
            borders.AddNewLeft().val    = (ST_Border.single);
            borders.AddNewRight().val   = (ST_Border.single);
            borders.AddNewTop().val     = (ST_Border.single);

            /*
             * CTTblGrid tblgrid=table.AddNewTblGrid();
             * tblgrid.AddNewGridCol().W=(new Bigint("2000"));
             */
            GetRows();
        }
Beispiel #3
0
        private void CreateEmptyTable(CT_Tbl table)
        {
            // MINIMUM ELEMENTS FOR A TABLE
            table.AddNewTr().AddNewTc().AddNewP();

            CT_TblPr tblpro = table.AddNewTblPr();

            if (!tblpro.IsSetTblW())
            {
                tblpro.AddNewTblW().w = "0";
            }
            tblpro.tblW.type = (ST_TblWidth.auto);

            // layout
            tblpro.AddNewTblLayout().type = ST_TblLayoutType.autofit;

            // borders
            CT_TblBorders borders = tblpro.AddNewTblBorders();

            borders.AddNewBottom().val  = ST_Border.single;
            borders.AddNewInsideH().val = ST_Border.single;
            borders.AddNewInsideV().val = ST_Border.single;
            borders.AddNewLeft().val    = ST_Border.single;
            borders.AddNewRight().val   = ST_Border.single;
            borders.AddNewTop().val     = ST_Border.single;


            CT_TblGrid tblgrid = table.AddNewTblGrid();

            tblgrid.AddNewGridCol().w = (ulong)2000;
        }
Beispiel #4
0
        /**
         * @param width
         */
        public void SetWidth(int width)
        {
            CT_TblPr    tblPr    = GetTrPr();
            CT_TblWidth tblWidth = tblPr.IsSetTblW() ? tblPr.tblW : tblPr
                                   .AddNewTblW();

            tblWidth.w = width.ToString();
        }
Beispiel #5
0
        public int GetWidth()
        {
            CT_TblPr trPr = this.GetTrPr();

            if (!trPr.IsSetTblW())
            {
                return(-1);
            }
            return(int.Parse(trPr.tblW.w));
        }
Beispiel #6
0
        public int GetColBandSize()
        {
            int      result = 0;
            CT_TblPr trPr   = this.GetTrPr();

            if (trPr.IsSetTblStyleColBandSize())
            {
                int.TryParse(trPr.tblStyleColBandSize.val, out result);
            }
            return(result);
        }
Beispiel #7
0
        public void SetRightBorder(XWPFBorderType type, int size, int space, String rgbColor)
        {
            CT_TblPr      tblPr = GetTrPr();
            CT_TblBorders ctb   = tblPr.IsSetTblBorders() ? tblPr.tblBorders : tblPr.AddNewTblBorders();
            CT_Border     b     = ctb.right != null ? ctb.right : ctb.AddNewRight();

            b.val   = xwpfBorderTypeMap[type];
            b.sz    = (ulong)size;
            b.space = (ulong)space;
            b.color = (rgbColor);
        }
Beispiel #8
0
        /**
         * Set the table style. If the style is not defined in the document, MS Word
         * will Set the table style to "Normal".
         * @param styleName - the style name to apply to this table
         */
        public void SetStyleID(String styleName)
        {
            CT_TblPr  tblPr    = GetTrPr();
            CT_String styleStr = tblPr.tblStyle;

            if (styleStr == null)
            {
                styleStr = tblPr.AddNewTblStyle();
            }
            styleStr.val = (styleName);
        }
Beispiel #9
0
        public void SetInsideVBorder(XWPFTable.XWPFBorderType type, int size, int space, string rgbColor)
        {
            CT_TblPr      trPr         = this.GetTrPr();
            CT_TblBorders ctTblBorders = trPr.IsSetTblBorders() ? trPr.tblBorders : trPr.AddNewTblBorders();
            CT_Border     ctBorder     = ctTblBorders.IsSetInsideV() ? ctTblBorders.insideV : ctTblBorders.AddNewInsideV();

            ctBorder.val   = XWPFTable.xwpfBorderTypeMap[type];
            ctBorder.sz    = (ulong)size;
            ctBorder.space = (ulong)space;
            ctBorder.color = rgbColor;
        }
Beispiel #10
0
        public void SetInsideVBorder(XWPFBorderType type, int size, int space, String rgbColor)
        {
            CT_TblPr      tblPr = GetTrPr();
            CT_TblBorders ctb   = tblPr.IsSetTblBorders() ? tblPr.tblBorders : tblPr.AddNewTblBorders();
            CT_Border     b     = ctb.IsSetInsideV() ? ctb.insideV : ctb.AddNewInsideV();

            b.val   = (xwpfBorderTypeMap[type]);
            b.sz    = (ulong)size;
            b.space = (ulong)space;
            b.color = (rgbColor);
        }
Beispiel #11
0
        /// <summary>
        /// word 插入表格功能(13行2列)
        /// </summary>
        /// <param name="m_Docx">根文档</param>
        /// <param name="device_type">设备类型</param>
        /// <param name="kilometer_mark">公里标</param>
        /// <param name="side_direction">下行侧向</param>
        /// <param name="longitude">经度</param>
        /// <param name="latitude">纬度</param>
        private static void word_inster_table(XWPFDocument m_Docx, DbBean bean, int i = 1)
        {
            XWPFTable table  = m_Docx.CreateTable(12, 2);
            CT_Tbl    ctbl   = m_Docx.Document.body.GetTblArray()[i];
            CT_TblPr  ctblpr = ctbl.AddNewTblPr();

            ctblpr.jc     = new CT_Jc();
            ctblpr.jc.val = ST_Jc.center;

            table.Width = 3500;
            table.GetRow(0).GetCell(0).SetText("设备类型");
            table.GetRow(0).GetCell(1).SetText(bean.DeviceType);
            table.GetRow(1).GetCell(0).SetText("公里标");
            table.GetRow(1).GetCell(1).SetText(bean.KilometerMark);
            table.GetRow(2).GetCell(0).SetText("下行侧向");
            table.GetRow(2).GetCell(1).SetText(bean.SideDirection);
            table.GetRow(3).GetCell(0).SetText("距线路中心距离(m)");
            table.GetRow(4).GetCell(0).SetText("经度");
            table.GetRow(4).GetCell(1).SetText(bean.Longitude);
            table.GetRow(5).GetCell(0).SetText("纬度");
            table.GetRow(5).GetCell(1).SetText(bean.Latitude);
            table.GetRow(6).GetCell(0).SetText("杆塔类型");
            table.GetRow(6).GetCell(1).SetText(bean.TowerType);
            table.GetRow(7).GetCell(0).SetText("杆塔高度");
            table.GetRow(7).GetCell(1).SetText(bean.TowerHeight);
            table.GetRow(8).GetCell(0).SetText("天线1方向角");
            table.GetRow(8).GetCell(1).SetText(bean.AntennaDirection1);
            table.GetRow(9).GetCell(0).SetText("天线2方向角");
            table.GetRow(9).GetCell(1).SetText(bean.AntennaDirection2);
            table.GetRow(10).GetCell(0).SetText("天线3方向角");
            table.GetRow(10).GetCell(1).SetText(bean.AntennaDirection3);
            table.GetRow(11).GetCell(0).SetText("天线4方向角");
            table.GetRow(11).GetCell(1).SetText(bean.AntennaDirection4);
            CT_TcPr m_Pr = table.GetRow(2).GetCell(1).GetCTTc().AddNewTcPr();

            m_Pr.tcW      = new CT_TblWidth();
            m_Pr.tcW.w    = "3500";
            m_Pr.tcW.type = ST_TblWidth.dxa; //设置单元格宽度

            XWPFTableRow  m_Row = table.InsertNewTableRow(0);
            XWPFTableCell cell  = m_Row.CreateCell();
            CT_Tc         cttc  = cell.GetCTTc();
            CT_TcPr       ctPr  = cttc.AddNewTcPr();

            ctPr.gridSpan     = new CT_DecimalNumber();
            ctPr.gridSpan.val = "2";
            cttc.GetPList()[0].AddNewR().AddNewT().Value = "SITE 【序号】";

            word_insert_space(1, m_Docx, 100);
            word_insert_text(m_Docx, "宋体", 11, "SITE 【序号】勘站照片");
            word_insert_text(m_Docx, "宋体", 11, "(3-10张照片)");

            word_insert_space(1, m_Docx, 100);
        }
Beispiel #12
0
        public int GetColBandSize()
        {
            int      size  = 0;
            CT_TblPr tblPr = GetTrPr();

            if (tblPr.IsSetTblStyleColBandSize())
            {
                CT_DecimalNumber colSize = tblPr.tblStyleColBandSize;
                int.TryParse(colSize.val, out size);
            }
            return(size);
        }
Beispiel #13
0
        public string GetInsideVBorderColor()
        {
            string   str  = (string)null;
            CT_TblPr trPr = this.GetTrPr();

            if (trPr.IsSetTblBorders())
            {
                CT_TblBorders tblBorders = trPr.tblBorders;
                if (tblBorders.IsSetInsideV())
                {
                    str = tblBorders.insideV.color;
                }
            }
            return(str);
        }
Beispiel #14
0
        public string GetStyleID()
        {
            string   str   = (string)null;
            CT_TblPr tblPr = this.ctTbl.tblPr;

            if (tblPr != null)
            {
                CT_String tblStyle = tblPr.tblStyle;
                if (tblStyle != null)
                {
                    str = tblStyle.val;
                }
            }
            return(str);
        }
Beispiel #15
0
        public int GetInsideVBorderSpace()
        {
            int      num  = -1;
            CT_TblPr trPr = this.GetTrPr();

            if (trPr.IsSetTblBorders())
            {
                CT_TblBorders tblBorders = trPr.tblBorders;
                if (tblBorders.IsSetInsideV())
                {
                    num = (int)tblBorders.insideV.space;
                }
            }
            return(num);
        }
Beispiel #16
0
        /**
         * Get the StyleID of the table
         * @return	style-ID of the table
         */
        public String GetStyleID()
        {
            String   styleId = null;
            CT_TblPr tblPr   = ctTbl.tblPr;

            if (tblPr != null)
            {
                CT_String styleStr = tblPr.tblStyle;
                if (styleStr != null)
                {
                    styleId = styleStr.val;
                }
            }
            return(styleId);
        }
Beispiel #17
0
        public int GetInsideHBorderSize()
        {
            int      num  = -1;
            CT_TblPr trPr = this.GetTrPr();

            if (trPr.IsSetTblBorders())
            {
                CT_TblBorders tblBorders = trPr.tblBorders;
                if (tblBorders.IsSetInsideH())
                {
                    num = (int)tblBorders.insideH.sz;
                }
            }
            return(num);
        }
Beispiel #18
0
        public XWPFTable.XWPFBorderType GetInsideVBorderType()
        {
            XWPFTable.XWPFBorderType xwpfBorderType = XWPFTable.XWPFBorderType.NONE;
            CT_TblPr trPr = this.GetTrPr();

            if (trPr.IsSetTblBorders())
            {
                CT_TblBorders tblBorders = trPr.tblBorders;
                if (tblBorders.IsSetInsideV())
                {
                    CT_Border insideV = tblBorders.insideV;
                    xwpfBorderType = XWPFTable.stBorderTypeMap[insideV.val];
                }
            }
            return(xwpfBorderType);
        }
Beispiel #19
0
        public int GetCellMarginRight()
        {
            int           margin = 0;
            CT_TblPr      tblPr  = GetTrPr();
            CT_TblCellMar tcm    = tblPr.tblCellMar;

            if (tcm != null)
            {
                CT_TblWidth tw = tcm.right;
                if (tw != null)
                {
                    int.TryParse(tw.w, out margin);
                }
            }
            return(margin);
        }
Beispiel #20
0
        /// <summary>
        /// 生成模板文件
        /// </summary>
        /// <param name="m_Docx">根文档</param>
        private static void word_init(XWPFDocument m_Docx)
        {
            //1‘=1440twip=25.4mm=72pt(磅point)=96px(像素pixel)
            //1px(像素pixel)=0.75pt(磅point)
            // A4:W=11906 twip=8.269''=210mm,h=16838twip=11.693''=297mm
            //A5:W=8390 twip=5.827''=148mm,h=11906 twip=8.269''=210mm
            //A6:W=5953 twip=4.134''=105mm,h=8390twip=5.827''=1148mm
            //16k195mmX270mm:
            //16k184mmX260mm:
            //16k197mmX273mm:
            CT_SectPr m_SectPr = new CT_SectPr();

            //页面设置A4纵向
            m_SectPr.pgSz.w             = (ulong)11906;
            m_SectPr.pgSz.h             = (ulong)16838;
            m_Docx.Document.body.sectPr = m_SectPr;
            //第一页
            word_insert_space(4, m_Docx);
            word_insert_text(m_Docx, "宋体", 22, "【项目名称】");
            word_insert_text(m_Docx, "宋体", 22, "GSM-R 通信系统");
            word_insert_text(m_Docx, "宋体", 22, "现场勘查报告");

            word_insert_space(8, m_Docx);
            word_insert_text(m_Docx, "宋体", 22, "【日期】");

            word_insert_space(7, m_Docx);
            //第二页
            //表1
            XWPFTable table  = m_Docx.CreateTable(4, 2);
            CT_Tbl    ctbl   = m_Docx.Document.body.GetTblArray()[0];
            CT_TblPr  ctblpr = ctbl.AddNewTblPr();

            ctblpr.jc     = new CT_Jc();
            ctblpr.jc.val = ST_Jc.center;
            table.Width   = 4000;
            table.GetRow(0).GetCell(0).SetText("项目");
            table.GetRow(1).GetCell(0).SetText("日期");
            table.GetRow(2).GetCell(0).SetText("现场勘查人员");
            table.GetRow(3).GetCell(0).SetText("报告编制人员");
            CT_TcPr m_Pr = table.GetRow(0).GetCell(1).GetCTTc().AddNewTcPr();

            m_Pr.tcW      = new CT_TblWidth();
            m_Pr.tcW.w    = "4000";
            m_Pr.tcW.type = ST_TblWidth.dxa; //设置单元格宽度
            word_insert_space(2, m_Docx);
            word_insert_text(m_Docx, "宋体", 12, "基站勘察表");
        }
Beispiel #21
0
        public int GetInsideVBorderSpace()
        {
            int space = -1;

            CT_TblPr tblPr = GetTrPr();

            if (tblPr.IsSetTblBorders())
            {
                CT_TblBorders ctb = tblPr.tblBorders;
                if (ctb.IsSetInsideV())
                {
                    CT_Border border = ctb.insideV;
                    space = (int)border.space;
                }
            }
            return(space);
        }
Beispiel #22
0
        public int GetInsideHBorderSize()
        {
            int size = -1;

            CT_TblPr tblPr = GetTrPr();

            if (tblPr.IsSetTblBorders())
            {
                CT_TblBorders ctb = tblPr.tblBorders;
                if (ctb.IsSetInsideH())
                {
                    CT_Border border = ctb.insideH;
                    size = (int)border.sz;
                }
            }
            return(size);
        }
Beispiel #23
0
        public XWPFBorderType GetInsideVBorderType()
        {
            XWPFBorderType bt = XWPFBorderType.NONE;

            CT_TblPr tblPr = GetTrPr();

            if (tblPr.IsSetTblBorders())
            {
                CT_TblBorders ctb = tblPr.tblBorders;
                if (ctb.IsSetInsideV())
                {
                    CT_Border border = ctb.insideV;
                    bt = stBorderTypeMap[border.val];
                }
            }
            return(bt);
        }
Beispiel #24
0
        public String GetInsideVBorderColor()
        {
            String color = null;

            CT_TblPr tblPr = GetTrPr();

            if (tblPr.IsSetTblBorders())
            {
                CT_TblBorders ctb = tblPr.tblBorders;
                if (ctb.IsSetInsideV())
                {
                    CT_Border border = ctb.insideV;
                    color = border.color;
                }
            }
            return(color);
        }
Beispiel #25
0
        private void CreateEmptyTable(CT_Tbl table)
        {
            table.AddNewTr().AddNewTc().AddNewP();
            CT_TblPr ctTblPr = table.AddNewTblPr();

            if (!ctTblPr.IsSetTblW())
            {
                ctTblPr.AddNewTblW().w = "0";
            }
            ctTblPr.tblW.type = ST_TblWidth.auto;
            CT_TblBorders ctTblBorders = ctTblPr.AddNewTblBorders();

            ctTblBorders.AddNewBottom().val  = ST_Border.single;
            ctTblBorders.AddNewInsideH().val = ST_Border.single;
            ctTblBorders.AddNewInsideV().val = ST_Border.single;
            ctTblBorders.AddNewLeft().val    = ST_Border.single;
            ctTblBorders.AddNewRight().val   = ST_Border.single;
            ctTblBorders.AddNewTop().val     = ST_Border.single;
            this.GetRows();
        }
Beispiel #26
0
        public void SetCellMargins(int top, int left, int bottom, int right)
        {
            CT_TblPr      trPr         = this.GetTrPr();
            CT_TblCellMar ctTblCellMar = trPr.IsSetTblCellMar() ? trPr.tblCellMar : trPr.AddNewTblCellMar();
            CT_TblWidth   ctTblWidth1  = ctTblCellMar.IsSetLeft() ? ctTblCellMar.left : ctTblCellMar.AddNewLeft();

            ctTblWidth1.type = ST_TblWidth.dxa;
            ctTblWidth1.w    = left.ToString();
            CT_TblWidth ctTblWidth2 = ctTblCellMar.IsSetTop() ? ctTblCellMar.top : ctTblCellMar.AddNewTop();

            ctTblWidth2.type = ST_TblWidth.dxa;
            ctTblWidth2.w    = top.ToString();
            CT_TblWidth ctTblWidth3 = ctTblCellMar.IsSetBottom() ? ctTblCellMar.bottom : ctTblCellMar.AddNewBottom();

            ctTblWidth3.type = ST_TblWidth.dxa;
            ctTblWidth3.w    = bottom.ToString();
            CT_TblWidth ctTblWidth4 = ctTblCellMar.IsSetRight() ? ctTblCellMar.right : ctTblCellMar.AddNewRight();

            ctTblWidth4.type = ST_TblWidth.dxa;
            ctTblWidth4.w    = right.ToString();
        }
Beispiel #27
0
        public void SetCellMargins(int top, int left, int bottom, int right)
        {
            CT_TblPr      tblPr = GetTrPr();
            CT_TblCellMar tcm   = tblPr.IsSetTblCellMar() ? tblPr.tblCellMar : tblPr.AddNewTblCellMar();

            CT_TblWidth tw = tcm.IsSetLeft() ? tcm.left : tcm.AddNewLeft();

            tw.type = (ST_TblWidth.dxa);
            tw.w    = left.ToString();

            tw      = tcm.IsSetTop() ? tcm.top : tcm.AddNewTop();
            tw.type = (ST_TblWidth.dxa);
            tw.w    = top.ToString();

            tw      = tcm.IsSetBottom() ? tcm.bottom : tcm.AddNewBottom();
            tw.type = (ST_TblWidth.dxa);
            tw.w    = bottom.ToString();

            tw      = tcm.IsSetRight() ? tcm.right : tcm.AddNewRight();
            tw.type = (ST_TblWidth.dxa);
            tw.w    = right.ToString();
        }
Beispiel #28
0
        public void SetStyleID(string styleName)
        {
            CT_TblPr trPr = this.GetTrPr();

            (trPr.tblStyle ?? trPr.AddNewTblStyle()).val = styleName;
        }
Beispiel #29
0
        public void SetColBandSize(int size)
        {
            CT_TblPr trPr = this.GetTrPr();

            (trPr.IsSetTblStyleColBandSize() ? trPr.tblStyleColBandSize : trPr.AddNewTblStyleColBandSize()).val = size.ToString();
        }
Beispiel #30
0
        public void SetWidth(int width)
        {
            CT_TblPr trPr = this.GetTrPr();

            (trPr.IsSetTblW() ? trPr.tblW : trPr.AddNewTblW()).w = width.ToString();
        }