Exemple #1
0
        /**
         * Create and Initialize a CT_TwoCellAnchor that anchors a shape against top-left and bottom-right cells.
         *
         * @return a new CT_TwoCellAnchor
         */
        private CT_TwoCellAnchor CreateTwoCellAnchor(IClientAnchor anchor)
        {
            CT_TwoCellAnchor ctAnchor   = drawing.AddNewTwoCellAnchor();
            XSSFClientAnchor xssfanchor = (XSSFClientAnchor)anchor;

            ctAnchor.from = (xssfanchor.GetFrom());
            ctAnchor.to   = (xssfanchor.GetTo());
            ctAnchor.AddNewClientData();
            xssfanchor.SetTo(ctAnchor.to);
            xssfanchor.SetFrom(ctAnchor.from);
            ST_EditAs aditAs;

            switch (anchor.AnchorType)
            {
            case (int)AnchorType.DONT_MOVE_AND_RESIZE:
                aditAs = ST_EditAs.absolute; break;

            case (int)AnchorType.MOVE_AND_RESIZE:
                aditAs = ST_EditAs.twoCell; break;

            case (int)AnchorType.MOVE_DONT_RESIZE:
                aditAs = ST_EditAs.oneCell; break;

            default:
                aditAs = ST_EditAs.oneCell;
                break;
            }
            ctAnchor.editAs          = aditAs;
            ctAnchor.editAsSpecified = true;
            return(ctAnchor);
        }
Exemple #2
0
        private CT_TwoCellAnchor CreateTwoCellAnchor(IClientAnchor anchor)
        {
            CT_TwoCellAnchor ctTwoCellAnchor  = this.drawing.AddNewTwoCellAnchor();
            XSSFClientAnchor xssfClientAnchor = (XSSFClientAnchor)anchor;

            ctTwoCellAnchor.from = xssfClientAnchor.GetFrom();
            ctTwoCellAnchor.to   = xssfClientAnchor.GetTo();
            ctTwoCellAnchor.AddNewClientData();
            xssfClientAnchor.SetTo(ctTwoCellAnchor.to);
            xssfClientAnchor.SetFrom(ctTwoCellAnchor.from);
            NPOI.OpenXmlFormats.Dml.Spreadsheet.ST_EditAs stEditAs;
            switch (anchor.AnchorType)
            {
            case 0:
                stEditAs = NPOI.OpenXmlFormats.Dml.Spreadsheet.ST_EditAs.twoCell;
                break;

            case 2:
                stEditAs = NPOI.OpenXmlFormats.Dml.Spreadsheet.ST_EditAs.oneCell;
                break;

            case 3:
                stEditAs = NPOI.OpenXmlFormats.Dml.Spreadsheet.ST_EditAs.absolute;
                break;

            default:
                stEditAs = NPOI.OpenXmlFormats.Dml.Spreadsheet.ST_EditAs.oneCell;
                break;
            }
            ctTwoCellAnchor.editAs          = stEditAs;
            ctTwoCellAnchor.editAsSpecified = true;
            return(ctTwoCellAnchor);
        }