Example #1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Sheet sheet = null;

            if (!DA.GetData(0, ref sheet))
            {
                return;
            }

            DA.SetData(0, sheet.Properties.Title);
            DA.SetData(1, sheet.Properties.SheetId);
            DA.SetData(2, sheet.Properties.Index);

            // empty tree for cell strings
            DataTree <string> rowsTree = new DataTree <string>();


            // extract strings, add to tree
            var rowData = sheet.Data[0].RowData;

            for (int i = 0; i < rowData.Count; i++)
            {
                // create new branch
                rowsTree.Insert("", new GH_Path(i), 0);
            }
            // clear dummy data
            rowsTree.ClearData();

            for (int i = 0; i < rowData.Count; i++)
            {
                List <string> rowStrings = new List <string>();
                if (!(rowData[i].Values is null))
                {
                    foreach (var value in rowData[i].Values)
                    {
                        //rowStrings.Add(value.EffectiveValue?.ToDataString());
                        rowStrings.Add(value.FormattedValue);
                    }
                }
                rowsTree.Branch(i).AddRange(rowStrings);
            }

            // set row data
            DA.SetDataTree(3, rowsTree);
        }