protected void AddDrawingsFromXml(ExcelWorksheet ws)
        {
            var nodes = VmlDrawingXml.SelectNodes("//v:shape", NameSpaceManager);

            //var list = new List<IRangeID>();
            foreach (XmlNode node in nodes)
            {
                var rowNode = node.SelectSingleNode("x:ClientData/x:Row", NameSpaceManager);
                var colNode = node.SelectSingleNode("x:ClientData/x:Column", NameSpaceManager);
                if (rowNode != null && colNode != null)
                {
                    var row = int.Parse(rowNode.InnerText) + 1;
                    var col = int.Parse(colNode.InnerText) + 1;
                    //list.Add(new ExcelVmlDrawingComment(node, ws.Cells[row, col], NameSpaceManager));
                    _drawings.SetValue(row, col, new ExcelVmlDrawingComment(node, ws.Cells[row, col], NameSpaceManager));
                }
                else
                {
                    //list.Add(new ExcelVmlDrawingComment(node, ws.Cells[1, 1], NameSpaceManager));
                    _drawings.SetValue(1, 1, new ExcelVmlDrawingComment(node, ws.Cells[1, 1], NameSpaceManager));
                }
            }
            //list.Sort(new Comparison<IRangeID>((r1, r2) => (r1.RangeID < r2.RangeID ? -1 : r1.RangeID > r2.RangeID ? 1 : 0)));  //Vml drawings are not sorted. Sort to avoid missmatches.
            //_drawings = new RangeCollection(list);
        }
 private void AddDrawingsFromXml()
 {
     var nodes = VmlDrawingXml.SelectNodes("//v:shape", NameSpaceManager);
     _images = new List<ExcelVmlDrawingPicture>();
     foreach (XmlNode node in nodes)
     {
         var img = new ExcelVmlDrawingPicture(node, NameSpaceManager, _ws);
         var rel = Part.GetRelationship(img.RelId);
         img.ImageUri = UriHelper.ResolvePartUri(rel.SourceUri, rel.TargetUri);
         _images.Add(img);
     }
 }
Exemple #3
0
        protected internal void AddDrawingsFromXml(ExcelWorksheet ws)
        {
            var nodes = VmlDrawingXml.SelectNodes("//v:shape", NameSpaceManager);

            //var list = new List<IRangeID>();
            foreach (XmlNode node in nodes)
            {
                var objectType = node.SelectSingleNode("x:ClientData/@ObjectType", NameSpaceManager)?.Value;
                ExcelVmlDrawingBase vmlDrawing;
                switch (objectType)
                {
                case "Drop":
                case "List":
                case "Button":
                case "GBox":
                case "Label":
                case "Checkbox":
                case "Spin":
                case "Radio":
                case "EditBox":
                case "Dialog":
                    vmlDrawing = new ExcelVmlDrawingControl(_ws, node, NameSpaceManager);
                    _drawings.Add(vmlDrawing);
                    break;

                default:        //Comments
                    var rowNode = node.SelectSingleNode("x:ClientData/x:Row", NameSpaceManager);
                    var colNode = node.SelectSingleNode("x:ClientData/x:Column", NameSpaceManager);
                    int row, col;
                    if (rowNode != null && colNode != null)
                    {
                        row = int.Parse(rowNode.InnerText) + 1;
                        col = int.Parse(colNode.InnerText) + 1;
                    }
                    else
                    {
                        row = 1;
                        col = 1;
                    }
                    vmlDrawing = new ExcelVmlDrawingComment(node, ws.Cells[row, col], NameSpaceManager);
                    _drawings.Add(vmlDrawing);
                    _drawingsCellStore.SetValue(row, col, _drawings.Count - 1);
                    break;
                }
                _drawingsDict.Add(string.IsNullOrEmpty(vmlDrawing.SpId) ? vmlDrawing.Id : vmlDrawing.SpId, _drawings.Count - 1);
            }
        }
        protected void AddDrawingsFromXml(ExcelWorksheet ws)
        {
            var nodes = VmlDrawingXml.SelectNodes("//v:shape", NameSpaceManager);
            var list  = new List <IRangeID>();

            foreach (XmlNode node in nodes)
            {
                var rowNode = node.SelectSingleNode("x:ClientData/x:Row", NameSpaceManager);
                var colNode = node.SelectSingleNode("x:ClientData/x:Column", NameSpaceManager);
                if (rowNode != null && colNode != null)
                {
                    var row = int.Parse(rowNode.InnerText) + 1;
                    var col = int.Parse(colNode.InnerText) + 1;
                    list.Add(new ExcelVmlDrawingComment(node, ws.Cells[row, col], NameSpaceManager));
                }
                else
                {
                    list.Add(new ExcelVmlDrawingComment(node, ws.Cells[1, 1], NameSpaceManager));
                }
            }
            _drawings = new RangeCollection(list);
        }