コード例 #1
0
        public XSSFPicture CreatePicture(XSSFClientAnchor anchor, int pictureIndex)
        {
            PackageRelationship rel       = this.GetDrawing().AddPictureReference(pictureIndex);
            CT_Picture          ctPicture = this.ctGroup.AddNewPic();

            ctPicture.Set(XSSFPicture.Prototype());
            XSSFPicture xssfPicture = new XSSFPicture(this.GetDrawing(), ctPicture);

            xssfPicture.parent = this;
            xssfPicture.anchor = (XSSFAnchor)anchor;
            xssfPicture.SetPictureReference(rel);
            return(xssfPicture);
        }
コード例 #2
0
        public IPicture CreatePicture(XSSFClientAnchor anchor, int pictureIndex)
        {
            PackageRelationship rel = this.AddPictureReference(pictureIndex);
            long       num          = this.newShapeId();
            CT_Picture ctPicture    = this.CreateTwoCellAnchor((IClientAnchor)anchor).AddNewPic();

            ctPicture.Set(XSSFPicture.Prototype());
            ctPicture.nvPicPr.cNvPr.id = (uint)num;
            XSSFPicture xssfPicture = new XSSFPicture(this, ctPicture);

            xssfPicture.anchor = (XSSFAnchor)anchor;
            xssfPicture.SetPictureReference(rel);
            return((IPicture)xssfPicture);
        }
コード例 #3
0
        /**
         * Creates a picture.
         *
         * @param anchor       the client anchor describes how this picture is attached to the sheet.
         * @param pictureIndex the index of the picture in the workbook collection of pictures,
         *                     {@link XSSFWorkbook#getAllPictures()} .
         * @return the newly Created picture shape.
         */
        public XSSFPicture CreatePicture(XSSFClientAnchor anchor, int pictureIndex)
        {
            PackageRelationship rel = GetDrawing().AddPictureReference(pictureIndex);

            CT_Picture ctShape = ctGroup.AddNewPic();

            ctShape.Set(XSSFPicture.Prototype());

            XSSFPicture shape = new XSSFPicture(GetDrawing(), ctShape);

            shape.parent = this;
            shape.anchor = anchor;
            shape.SetPictureReference(rel);
            return(shape);
        }
コード例 #4
0
        /**
         * Creates a picture.
         *
         * @param anchor    the client anchor describes how this picture is attached to the sheet.
         * @param pictureIndex the index of the picture in the workbook collection of pictures,
         *   {@link NPOI.xssf.usermodel.XSSFWorkbook#getAllPictures()} .
         *
         * @return  the newly Created picture shape.
         */
        public IPicture CreatePicture(XSSFClientAnchor anchor, int pictureIndex)
        {
            PackageRelationship rel = AddPictureReference(pictureIndex);

            long             shapeId  = newShapeId();
            CT_TwoCellAnchor ctAnchor = CreateTwoCellAnchor(anchor);
            CT_Picture       ctShape  = ctAnchor.AddNewPic();

            ctShape.Set(XSSFPicture.Prototype());

            ctShape.nvPicPr.cNvPr.id = (uint)shapeId;

            XSSFPicture shape = new XSSFPicture(this, ctShape);

            shape.anchor = anchor;
            shape.SetPictureReference(rel);
            return(shape);
        }
コード例 #5
0
        /*
         * This is the default Watermark paragraph; the only variable is the text message
         * TODO: manage all the other variables
         */
        private XWPFParagraph GetWatermarkParagraph(String text, int idx)
        {
            CT_P p = new CT_P();

            byte[] rsidr        = doc.Document.body.GetPArray(0).rsidR;
            byte[] rsidrdefault = doc.Document.body.GetPArray(0).rsidRDefault;
            p.rsidP        = (rsidr);
            p.rsidRDefault = (rsidrdefault);
            CT_PPr pPr = p.AddNewPPr();

            pPr.AddNewPStyle().val = ("Header");
            // start watermark paragraph
            Npoi.Core.OpenXmlFormats.Wordprocessing.CT_R r = p.AddNewR();
            CT_RPr rPr = r.AddNewRPr();

            rPr.AddNewNoProof();
            CT_Picture pict = r.AddNewPict();

            CT_Group     group     = new CT_Group();
            CT_Shapetype shapetype = group.AddNewShapetype();

            shapetype.id        = ("_x0000_t136");
            shapetype.coordsize = ("1600,21600");
            shapetype.spt       = (136);
            shapetype.adj       = ("10800");
            shapetype.path2     = ("m@7,0l@8,0m@5,21600l@6,21600e");
            CT_Formulas formulas = shapetype.AddNewFormulas();

            formulas.AddNewF().eqn = ("sum #0 0 10800");
            formulas.AddNewF().eqn = ("prod #0 2 1");
            formulas.AddNewF().eqn = ("sum 21600 0 @1");
            formulas.AddNewF().eqn = ("sum 0 0 @2");
            formulas.AddNewF().eqn = ("sum 21600 0 @3");
            formulas.AddNewF().eqn = ("if @0 @3 0");
            formulas.AddNewF().eqn = ("if @0 21600 @1");
            formulas.AddNewF().eqn = ("if @0 0 @2");
            formulas.AddNewF().eqn = ("if @0 @4 21600");
            formulas.AddNewF().eqn = ("mid @5 @6");
            formulas.AddNewF().eqn = ("mid @8 @5");
            formulas.AddNewF().eqn = ("mid @7 @8");
            formulas.AddNewF().eqn = ("mid @6 @7");
            formulas.AddNewF().eqn = ("sum @6 0 @5");
            CT_Path path           = shapetype.AddNewPath();

            path.textpathok    = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.t);
            path.connecttype   = (ST_ConnectType.custom);
            path.connectlocs   = ("@9,0;@10,10800;@11,21600;@12,10800");
            path.connectangles = ("270,180,90,0");
            CT_TextPath shapeTypeTextPath = shapetype.AddNewTextpath();

            shapeTypeTextPath.on       = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.t);
            shapeTypeTextPath.fitshape = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.t);
            CT_Handles handles = shapetype.AddNewHandles();
            CT_H       h       = handles.AddNewH();

            h.position = ("#0,bottomRight");
            h.xrange   = ("6629,14971");
            Npoi.Core.OpenXmlFormats.Vml.Office.CT_Lock lock1 = shapetype.AddNewLock();
            lock1.ext = (ST_Ext.edit);
            CT_Shape shape = group.AddNewShape();

            shape.id         = ("PowerPlusWaterMarkObject" + idx);
            shape.spid       = ("_x0000_s102" + (4 + idx));
            shape.type       = ("#_x0000_t136");
            shape.style      = ("position:absolute;margin-left:0;margin-top:0;width:415pt;height:207.5pt;z-index:-251654144;mso-wrap-edited:f;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin");
            shape.wrapcoords = ("616 5068 390 16297 39 16921 -39 17155 7265 17545 7186 17467 -39 17467 18904 17467 10507 17467 8710 17545 18904 17077 18787 16843 18358 16297 18279 12554 19178 12476 20701 11774 20779 11228 21131 10059 21248 8811 21248 7563 20975 6316 20935 5380 19490 5146 14022 5068 2616 5068");
            shape.fillcolor  = ("black");
            shape.stroked    = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.@false);
            CT_TextPath shapeTextPath = shape.AddNewTextpath();

            shapeTextPath.style   = ("font-family:"Cambria";font-size:1pt");
            shapeTextPath.@string = (text);
            pict.Set(group);
            // end watermark paragraph
            return(new XWPFParagraph(p, doc));
        }
コード例 #6
0
        private XWPFParagraph GetWatermarkParagraph(string text, int idx)
        {
            CT_P prgrph = new CT_P();

            byte[] rsidR        = this.doc.Document.body.GetPArray(0).rsidR;
            byte[] rsidRdefault = this.doc.Document.body.GetPArray(0).rsidRDefault;
            prgrph.rsidP        = rsidR;
            prgrph.rsidRDefault = rsidRdefault;
            prgrph.AddNewPPr().AddNewPStyle().val       = "Header";
            NPOI.OpenXmlFormats.Wordprocessing.CT_R ctR = prgrph.AddNewR();
            ctR.AddNewRPr().AddNewNoProof();
            CT_Picture   ctPicture   = ctR.AddNewPict();
            CT_Group     ctGroup     = new CT_Group();
            CT_Shapetype ctShapetype = ctGroup.AddNewShapetype();

            ctShapetype.id        = "_x0000_t136";
            ctShapetype.coordsize = "1600,21600";
            ctShapetype.spt       = 136f;
            ctShapetype.adj       = "10800";
            ctShapetype.path2     = "m@7,0l@8,0m@5,21600l@6,21600e";
            CT_Formulas ctFormulas = ctShapetype.AddNewFormulas();

            ctFormulas.AddNewF().eqn = "sum #0 0 10800";
            ctFormulas.AddNewF().eqn = "prod #0 2 1";
            ctFormulas.AddNewF().eqn = "sum 21600 0 @1";
            ctFormulas.AddNewF().eqn = "sum 0 0 @2";
            ctFormulas.AddNewF().eqn = "sum 21600 0 @3";
            ctFormulas.AddNewF().eqn = "if @0 @3 0";
            ctFormulas.AddNewF().eqn = "if @0 21600 @1";
            ctFormulas.AddNewF().eqn = "if @0 0 @2";
            ctFormulas.AddNewF().eqn = "if @0 @4 21600";
            ctFormulas.AddNewF().eqn = "mid @5 @6";
            ctFormulas.AddNewF().eqn = "mid @8 @5";
            ctFormulas.AddNewF().eqn = "mid @7 @8";
            ctFormulas.AddNewF().eqn = "mid @6 @7";
            ctFormulas.AddNewF().eqn = "sum @6 0 @5";
            CT_Path ctPath           = ctShapetype.AddNewPath();

            ctPath.textpathok    = ST_TrueFalse.t;
            ctPath.connecttype   = ST_ConnectType.custom;
            ctPath.connectlocs   = "@9,0;@10,10800;@11,21600;@12,10800";
            ctPath.connectangles = "270,180,90,0";
            CT_TextPath ctTextPath1 = ctShapetype.AddNewTextpath();

            ctTextPath1.on       = ST_TrueFalse.t;
            ctTextPath1.fitshape = ST_TrueFalse.t;
            CT_H ctH = ctShapetype.AddNewHandles().AddNewH();

            ctH.position = "#0,bottomRight";
            ctH.xrange   = "6629,14971";
            ctShapetype.AddNewLock().ext = ST_Ext.edit;
            CT_Shape ctShape             = ctGroup.AddNewShape();

            ctShape.id         = "PowerPlusWaterMarkObject" + (object)idx;
            ctShape.spid       = "_x0000_s102" + (object)(4 + idx);
            ctShape.type       = "#_x0000_t136";
            ctShape.style      = "position:absolute;margin-left:0;margin-top:0;width:415pt;height:207.5pt;z-index:-251654144;mso-wrap-edited:f;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin";
            ctShape.wrapcoords = "616 5068 390 16297 39 16921 -39 17155 7265 17545 7186 17467 -39 17467 18904 17467 10507 17467 8710 17545 18904 17077 18787 16843 18358 16297 18279 12554 19178 12476 20701 11774 20779 11228 21131 10059 21248 8811 21248 7563 20975 6316 20935 5380 19490 5146 14022 5068 2616 5068";
            ctShape.fillcolor  = "black";
            ctShape.stroked    = ST_TrueFalse.@false;
            CT_TextPath ctTextPath2 = ctShape.AddNewTextpath();

            ctTextPath2.style   = "font-family:"Cambria";font-size:1pt";
            ctTextPath2.@string = text;
            ctPicture.Set((object)ctGroup);
            return(new XWPFParagraph(prgrph, (IBody)this.doc));
        }