An Excel shape.
Inheritance: ExcelDrawing
Esempio n. 1
0
        private void AddDrawings()
        {
            _groupDrawings = new List <ExcelDrawing>();
            foreach (XmlNode node in _topNode.ChildNodes)
            {
                ExcelDrawing grpDraw;
                switch (node.LocalName)
                {
                case "sp":
                    grpDraw = new ExcelShape(_parent._drawings, node, _parent);
                    break;

                case "pic":
                    grpDraw = new ExcelPicture(_parent._drawings, node, _parent);
                    break;

                case "graphicFrame":
                    grpDraw = ExcelChart.GetChart(_parent._drawings, node, _parent);
                    break;

                case "grpSp":
                    grpDraw = new ExcelGroupShape(_parent._drawings, node, _parent);
                    break;

                case "cxnSp":
                    grpDraw = new ExcelConnectionShape(_parent._drawings, node, _parent);
                    break;

                default:
                    continue;
                }
                _groupDrawings.Add(grpDraw);
                _drawingNames.Add(grpDraw.Name, _groupDrawings.Count - 1);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Add a new shape to the worksheet.
        /// </summary>
        /// <param name="name">The name of the shape.</param>
        /// <param name="style">The style of the shape.</param>
        /// <returns>Returns the newly created <see cref="ExcelShape"/>.</returns>
        public ExcelShape AddShape(string name, eShapeStyle style)
        {
            if (this.Worksheet is ExcelChartsheet && this._drawings.Count > 0)
            {
                throw new InvalidOperationException("Chart worksheets can't have more than one drawing");
            }
            XmlElement drawNode = this.CreateDrawingXml();
            ExcelShape shape    = new ExcelShape(this, drawNode, style);

            shape.Name  = name;
            shape.Style = style;
            this._drawings.Add(shape);
            return(shape);
        }
Esempio n. 3
0
        /// <summary>
        /// Add a new shape to the worksheet
        /// </summary>
        /// <param name="Name">Name</param>
        /// <param name="Style">Shape style</param>
        /// <returns>The shape object</returns>

        public ExcelShape AddShape(string Name, eShapeStyle Style)
        {
            if (_drawingNames.ContainsKey(Name.ToLower()))
            {
                throw new Exception("Name already exists in the drawings collection");
            }
            XmlElement drawNode = CreateDrawingXml();
            ExcelShape shape    = new ExcelShape(this, drawNode, Style);

            shape.Name  = Name;
            shape.Style = Style;
            _drawings.Add(shape);
            _drawingNames.Add(Name.ToLower(), _drawings.Count - 1);
            return(shape);
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a new shape to the worksheet
        /// </summary>
        /// <param name="Name">Name</param>
        /// <param name="Style">Shape style</param>
        /// <returns>The shape object</returns>

        public ExcelShape AddShape(string Name, eShapeStyle Style)
        {
            if (Worksheet is ExcelChartsheet && _drawings.Count > 0)
            {
                throw new InvalidOperationException("Chart worksheets can't have more than one drawing");
            }
            if (_drawingNames.ContainsKey(Name))
            {
                throw new Exception("Name already exists in the drawings collection");
            }
            XmlElement drawNode = CreateDrawingXml();

            ExcelShape shape = new ExcelShape(this, drawNode, Style);

            shape.Name = Name;
            _drawings.Add(shape);
            _drawingNames.Add(Name, _drawings.Count - 1);
            return(shape);
        }
Esempio n. 5
0
 /// <summary>
 /// Add a new shape to the worksheet
 /// </summary>
 /// <param name="Name">Name</param>
 /// <param name="Style">Shape style</param>
 /// <returns>The shape object</returns>
 public ExcelShape AddShape(string Name, eShapeStyle Style)
 {
     if (_drawingNames.ContainsKey(Name.ToLower()))
         {
             throw new Exception("Name already exist in the drawings collection");
         }
         XmlElement drawNode = CreateDrawingXml();
         ExcelShape shape = new ExcelShape(this, drawNode, Style);
         shape.Name = Name;
         shape.Style = Style;
         _drawings.Add(shape);
         _drawingNames.Add(Name.ToLower(), _drawings.Count - 1);
         return shape;
 }
Esempio n. 6
0
        internal ExcelConnectionShape(ExcelDrawings drawings, XmlNode node, eShapeConnectorStyle style, ExcelShape startShape, ExcelShape endShape) :
            base(drawings, node, "xdr:cxnSp", "xdr:nvCxnSpPr/xdr:cNvPr")
        {
            XmlElement shapeNode = node.OwnerDocument.CreateElement("xdr", "cxnSp", ExcelPackage.schemaSheetDrawings);

            shapeNode.SetAttribute("macro", "");
            node.AppendChild(shapeNode);

            shapeNode.InnerXml = ShapeStartXml();
            node.AppendChild(shapeNode.OwnerDocument.CreateElement("xdr", "clientData", ExcelPackage.schemaSheetDrawings));

            Init(drawings, node);
            ConnectionStart.Shape = startShape;
            ConnectionEnd.Shape   = endShape;
            Style = style;
        }