├── .gitignore
├── ExcelPlus
├── Classes
│ ├── ExBorder.cs
│ ├── ExCell.cs
│ ├── ExConditions.cs
│ ├── ExEnums.cs
│ ├── ExFont.cs
│ ├── ExGraphic.cs
│ ├── ExRange.cs
│ ├── ExShape.cs
│ ├── ExSpark.cs
│ ├── ExWorkbook.cs
│ └── ExWorksheet.cs
├── Components
│ ├── Analysis
│ │ ├── GH_XL_Con_Bar.cs
│ │ ├── GH_XL_Con_Between.cs
│ │ ├── GH_XL_Con_Blank.cs
│ │ ├── GH_XL_Con_Percent.cs
│ │ ├── GH_XL_Con_Scale.cs
│ │ ├── GH_XL_Con_SparkBar.cs
│ │ ├── GH_XL_Con_SparkLine.cs
│ │ ├── GH_XL_Con_Text.cs
│ │ ├── GH_XL_Con_Top.cs
│ │ ├── GH_XL_Con_Unique.cs
│ │ ├── GH_XL_Con_Value.cs
│ │ └── GH_XL_Con__Base.cs
│ ├── Cell
│ │ ├── GH_XL_Cel_Address.cs
│ │ ├── GH_XL_Cel_Cells.cs
│ │ ├── GH_XL_Cel_Construct.cs
│ │ ├── GH_XL_Cel_Location.cs
│ │ └── GH_XL_Cel__Base.cs
│ ├── Format
│ │ ├── GH_XL_Frm_Clear.cs
│ │ ├── GH_XL_Frm_Size.cs
│ │ ├── GH_XL_Frm__Base.cs
│ │ ├── GH_XL_Gph_Border.cs
│ │ ├── GH_XL_Gph_Fill.cs
│ │ ├── GH_XL_Gph_Font.cs
│ │ └── GH_XL_Gph__Base.cs
│ ├── Range
│ │ ├── GH_XL_Rng_Construct.cs
│ │ ├── GH_XL_Rng_Deconstruct.cs
│ │ ├── GH_XL_Rng_Explode.cs
│ │ ├── GH_XL_Rng_Extents.cs
│ │ ├── GH_XL_Rng_GetCell.cs
│ │ ├── GH_XL_Rng_Merge.cs
│ │ ├── GH_XL_Rng_Populate.cs
│ │ ├── GH_XL_Rng_SubRanges.cs
│ │ ├── GH_XL_Rng__Base.cs
│ │ └── RH_XL_Wbk_AddRange.cs
│ ├── Workbook
│ │ ├── GH_XL_Wbk_Construct.cs
│ │ ├── GH_XL_Wbk_Deconstruct.cs
│ │ ├── GH_XL_Wbk_Open.cs
│ │ ├── GH_XL_Wbk_Properties.cs
│ │ ├── GH_XL_Wbk_Read.cs.cs
│ │ ├── GH_XL_Wbk_Run.cs
│ │ ├── GH_XL_Wbk_Save.cs
│ │ ├── GH_XL_Wbk_Write.cs
│ │ └── GH_XL_Wbk__Base.cs
│ └── Worksheet
│ │ ├── GH_XL_Wks_Construct.cs
│ │ ├── GH_XL_Wks_Deconstruct.cs
│ │ ├── GH_XL_Wks_PlaceImage.cs
│ │ ├── GH_XL_Wks_Properties.cs
│ │ └── GH_XL_Wks__Base.cs
├── ExcelPlus.csproj
├── ExcelPlus.sln
├── ExcelPlusInfo.cs
├── Extensions
│ ├── GhExtensions.cs
│ └── XlExtensions.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── Resources
│ ├── ExcelPlus-24.png
│ ├── ExcelPlus-Tab-16.png
│ ├── XL-Cel-Add.png
│ ├── XL-Cel-Address.png
│ ├── XL-Cel-Clear.png
│ ├── XL-Cel-Construct.png
│ ├── XL-Cel-GetCells2.png
│ ├── XL-Cel-Location.png
│ ├── XL-Cel-Value2.png
│ ├── XL-Con-Bars.png
│ ├── XL-Con-Between.png
│ ├── XL-Con-Blank.png
│ ├── XL-Con-Count.png
│ ├── XL-Con-Percent.png
│ ├── XL-Con-Scale.png
│ ├── XL-Con-SparkBar.png
│ ├── XL-Con-SparkLine.png
│ ├── XL-Con-Text.png
│ ├── XL-Con-Unique.png
│ ├── XL-Con-Value.png
│ ├── XL-Grp-BorderHorizontal.png
│ ├── XL-Grp-BorderVertial.png
│ ├── XL-Grp-Fill.png
│ ├── XL-Grp-Font.png
│ ├── XL-Grp-Size.png
│ ├── XL-Rng-Add.png
│ ├── XL-Rng-By.png
│ ├── XL-Rng-Compile.png
│ ├── XL-Rng-Deconstruct.png
│ ├── XL-Rng-Explode.png
│ ├── XL-Rng-Extents.png
│ ├── XL-Rng-GetCell.png
│ ├── XL-Rng-GetCells.png
│ ├── XL-Rng-Merge.png
│ ├── XL-Rng-Populate.png
│ ├── XL-Shp-Image.png
│ ├── XL-Wbk-Add.png
│ ├── XL-Wbk-Deconstruct.png
│ ├── XL-Wbk-Edit.png
│ ├── XL-Wbk-Open.png
│ ├── XL-Wbk-Read.png
│ ├── XL-Wbk-Refresh.png
│ ├── XL-Wbk-Save.png
│ ├── XL-Wbk-Wrt.png
│ ├── XL-Wks-Add.png
│ ├── XL-Wks-Deconstruct.png
│ └── XL-Wks-Edit.png
├── Utilities
│ ├── Constants.cs
│ └── Helper.cs
├── app.config
└── packages.config
├── LICENSE
└── README.md
/ExcelPlus/Classes/ExBorder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | using Sd = System.Drawing;
8 |
9 | using XL = ClosedXML.Excel;
10 |
11 | namespace ExcelPlus
12 | {
13 | public class ExBorder
14 | {
15 | #region members
16 | protected LineTypes lineType = LineTypes.Medium;
17 | protected Sd.Color color = Sd.Color.Transparent;
18 | protected bool active = false;
19 | #endregion
20 |
21 | #region constructor
22 |
23 | public ExBorder()
24 | {
25 |
26 | }
27 |
28 | public ExBorder(ExBorder border)
29 | {
30 | this.lineType = border.lineType;
31 | this.color = border.color;
32 | this.active = border.active;
33 | }
34 |
35 | public ExBorder(XL.XLBorderStyleValues lineType, XL.XLColor color, XL.IXLWorkbook workbook)
36 | {
37 | this.lineType = lineType.ToPlus();
38 | this.color = color.ToColor(workbook);
39 | this.active = !(this.lineType == LineTypes.None);
40 | }
41 |
42 | #endregion
43 |
44 | #region properties
45 |
46 | public virtual bool Active
47 | {
48 | get { return this.active; }
49 | }
50 |
51 | public LineTypes LineType
52 | {
53 | get { return this.lineType; }
54 | set { this.lineType = value; this.active = true; }
55 | }
56 |
57 | public Sd.Color Color
58 | {
59 | get { return this.color; }
60 | set { this.color = value; this.active = true; }
61 | }
62 |
63 | #endregion
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/ExcelPlus/Classes/ExEnums.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExcelPlus
8 | {
9 |
10 | public enum ContentTypes { Value, Formula };
11 | public enum Borders { Bottom, Top, Left, Right, Inside, Outside };
12 | public enum HorizontalBorders { None, Bottom, Top, Both, Between, All };
13 | public enum VerticalBorders { None, Left, Right, Both, Between, All };
14 | public enum LineTypes { None, Hair, Thin, Medium, Thick, Double, SlantDashDot, DashDot, DashDotDot, Dashed, Dotted, MediumDashDot, MediumDashDotDot, MediumDashed};
15 | public enum BorderWeights { Hairline, Thin, Medium, Thick, None };
16 | public enum Justifications { None, BottomLeft, BottomMiddle, BottomRight, CenterLeft, CenterMiddle, CenterRight, TopLeft, TopMiddle, TopRight };
17 | public enum ConditionalTypes { None, Average, Bars, Between, Blanks, Scale, Count, Percent, Text, Unique, Value };
18 | public enum ValueCondition { Greater, GreaterEqual, Less, LessEqual, Equal, NotEqual };
19 | public enum TextCondition { Begins, Contains, Ends, Equal, NotContains, NotEqual };
20 | public enum AverageCondition { AboveAverage, AboveEqualAverage, AboveDeviation, BelowAverage, BelowEqualAverage, BelowDeviation };
21 | public enum VbModuleType { ClassModule, Document, MSForm, StdModule, ActiveX };
22 | public enum ChartFill { Cluster, Stack, Fill };
23 | public enum RadialChartType { Pie, Pie3D, Donut, Radar, RadarFilled };
24 | public enum BarChartType { Basic, Box, Pyramid, Cylinder, Cone };
25 | public enum LineChartType { Line, LineMarkers, Area, Area3d };
26 | public enum ScatterChartType { Scatter, ScatterLines, ScatterSmooth, Bubble, Bubble3D };
27 | public enum SurfaceChartType { Surface, SurfaceWireframe, SurfaceTop, SurfaceWireframeTop };
28 | public enum LegendLocations { None, Left, Right, Top, Bottom };
29 | public enum LabelType { None, Value, Category };
30 | public enum GridType { None, Primary, All };
31 | public enum ShapeList { AlternatingFlow, AlternatingHexagons, BasicBlockList, CircleAccentTimeline, ConvergingArrows, DivergingArrows, Grouped, HorizontalBullet, LinearVenn, Lined, MultidirectionalCycle, NondirectionalCycle, Process, SquareAccent, Stacked, Trapezoid, VerticalAccent, VerticalArrow, VerticalBlock, VerticalBox, VerticalBullet, VerticalCircle };
32 | public enum ArrowStyle { None, Open, Oval, Diamond, Stealth, Triangle };
33 | public enum ShapeTypes { Image, Control, Figure, Line, SmartArt };
34 | public enum ShapeArrow { Right, Left, Up, Down, LeftRight, UpDown, Quad, LeftRightUp, Bent, UTurn, LeftUp, BentUp, CurvedRight, CurvedLeft, CurvedUp, CurvedDown, StripedRight, NotchedRight, Circular, Swoosh, LeftCircular, LeftRightCircular };
35 | public enum ShapeStar { Pt4, Pt5, Pt6, Pt7, Pt8, Pt10, Pt12, Pt16, Pt24, Pt32 };
36 | public enum ShapeFlowChart { Process, AlternateProcess, Decision, Data, PredefinedProcess, InternalStorage, Document, Multidocument, Terminator, Preparation, ManualInput, ManualOperation, Connector, OfflineStorage, OffpageConnector, Card, PunchedTape, SummingJunction, Or, Collate, Sort, Extract, Merge, StoredData, Delay, SequentialAccessStorage, MagneticDisk, DirectAccessStorage, Display };
37 | public enum ShapeSymbol { Plus, Minus, Multiply, Divide, Equal, NotEqual, LeftBracket, RightBracket, DoubleBracket, LeftBrace, RightBrace, DoubleBrace };
38 | public enum ShapeGeometry { Rectangle, Parallelogram, Trapezoid, Diamond, RoundedRectangle, Octagon, IsoscelesTriangle, RightTriangle, Oval, Hexagon, Cross, RegularPentagon, Pentagon, Donut, BlockArc, NonIsoscelesTrapezoid, Decagon, Heptagon, Dodecagon, Round1Rectangle, Round2SameRectangle, SnipRoundRectangle, Snip1Rectangle, Snip2SameRectangle, Round2DiagRectangle, Snip2DiagRectangle };
39 | public enum ShapeFigure { Can, Cube, Bevel, FoldedCorner, SmileyFace, NoSymbol, Heart, LightningBolt, Sun, Moon, Arc, Plaque, Cloud, Gear6, Gear9, Funnel, Chevron, Explosion1, Balloon, Explosion2, Wave, DoubleWave, DiagonalStripe, Pie, Frame, HalfFrame, Tear, Chord, Corner, PieWedge };
40 | public enum Extensions { xlsx, xlsm };
41 |
42 | public enum DataType { String,Integer,Number,Date};
43 | }
--------------------------------------------------------------------------------
/ExcelPlus/Classes/ExFont.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | using Sd = System.Drawing;
8 |
9 | using XL = ClosedXML.Excel;
10 |
11 | namespace ExcelPlus
12 | {
13 | public class ExFont
14 | {
15 |
16 | #region members
17 |
18 | protected string family = "None";
19 | protected double size = -1;
20 | protected Sd.Color color = Sd.Color.Transparent;
21 | protected Justifications justification = Justifications.BottomLeft;
22 | protected bool isBold = false;
23 | protected bool isItalic = false;
24 | protected bool isUnderlined = false;
25 | protected bool active = false;
26 |
27 | #endregion
28 |
29 | #region constructors
30 |
31 | public ExFont()
32 | {
33 |
34 | }
35 |
36 | public ExFont(ExFont font)
37 | {
38 | this.family = font.family;
39 | this.size = font.size;
40 | this.color = font.color;
41 | this.justification = font.justification;
42 | this.isBold = font.isBold;
43 | this.isItalic = font.isItalic;
44 | this.isUnderlined = font.isUnderlined;
45 | this.active = font.active;
46 | }
47 |
48 | public ExFont(XL.IXLStyle style, XL.IXLWorkbook workbook)
49 | {
50 | this.color = style.Font.FontColor.ToColor(workbook);
51 | this.family = style.Font.FontName;
52 | this.size = style.Font.FontSize;
53 | this.isBold = style.Font.Bold;
54 | this.isItalic= style.Font.Italic;
55 | this.isUnderlined = !(style.Font.Underline == XL.XLFontUnderlineValues.None);
56 | this.justification = style.Alignment.Horizontal.ToJustification(style.Alignment.Vertical);
57 | this.active = true;
58 | }
59 |
60 |
61 | #endregion
62 |
63 | #region properties
64 |
65 | public virtual bool Active
66 | {
67 | get { return active; }
68 | }
69 |
70 | public virtual string Family
71 | {
72 | get { return this.family; }
73 | set { this.family = value; this.active = true; }
74 | }
75 |
76 | public virtual bool HasFamily
77 | {
78 | get { return this.family != "None"; }
79 | }
80 |
81 | public virtual double Size
82 | {
83 | get { return this.size; }
84 | set { this.size = value; active = true; }
85 | }
86 |
87 | public virtual bool HasSize
88 | {
89 | get { return this.size > 0; }
90 | }
91 |
92 | public virtual Sd.Color Color
93 | {
94 | get { return this.color; }
95 | set { this.color = value; }
96 | }
97 |
98 | public virtual bool HasColor
99 | {
100 | get { return this.color != Sd.Color.Transparent; }
101 | }
102 |
103 | public virtual Justifications Justification
104 | {
105 | get { return this.justification; }
106 | set { this.justification = value; }
107 | }
108 |
109 | public virtual bool HasJustification
110 | {
111 | get { return this.justification != Justifications.None; }
112 | }
113 |
114 | public virtual bool IsBold
115 | {
116 | get { return this.isBold; }
117 | set { this.isBold = value; }
118 | }
119 |
120 | public virtual bool IsItalic
121 | {
122 | get { return this.isItalic; }
123 | set { this.isItalic = value; }
124 | }
125 |
126 | public virtual bool IsUnderlined
127 | {
128 | get { return this.isUnderlined; }
129 | set { this.isUnderlined = value; }
130 | }
131 |
132 | #endregion
133 |
134 | #region methods
135 |
136 | public void Apply(XL.IXLStyle input)
137 | {
138 | if (this.Active)
139 | {
140 | if (this.HasColor) input.Font.SetFontColor(this.Color.ToExcel());
141 | if (this.HasFamily) input.Font.SetFontName(this.Family);
142 | if (this.HasSize) input.Font.SetFontSize(this.Size);
143 | if (this.HasJustification)
144 | {
145 | input.Alignment.Horizontal = this.Justification.ToExcelHAlign();
146 | input.Alignment.Vertical = this.Justification.ToExcelVAlign();
147 | }
148 | input.Font.SetBold(this.IsBold);
149 | input.Font.SetItalic(this.IsItalic);
150 | if (this.IsUnderlined)
151 | {
152 | input.Font.SetUnderline(XL.XLFontUnderlineValues.Single);
153 | }
154 | else
155 | {
156 | input.Font.SetUnderline(XL.XLFontUnderlineValues.None);
157 | }
158 | }
159 | }
160 |
161 | #endregion
162 |
163 | }
164 | }
--------------------------------------------------------------------------------
/ExcelPlus/Classes/ExGraphic.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | using Sd = System.Drawing;
8 |
9 | using XL = ClosedXML.Excel;
10 |
11 | namespace ExcelPlus
12 | {
13 | public class ExGraphic
14 | {
15 |
16 | #region members
17 |
18 | protected ExBorder borderTop = new ExBorder();
19 | protected ExBorder borderBottom = new ExBorder();
20 | protected ExBorder borderRight = new ExBorder();
21 | protected ExBorder borderLeft = new ExBorder();
22 | protected ExBorder borderInside = new ExBorder();
23 | protected ExBorder borderOutside = new ExBorder();
24 |
25 | protected Sd.Color fillColor = Sd.Color.Transparent;
26 |
27 | protected bool active = false;
28 |
29 | #endregion
30 |
31 | #region constructors
32 |
33 | public ExGraphic()
34 | {
35 |
36 | }
37 |
38 | public ExGraphic(ExGraphic graphic)
39 | {
40 | this.borderTop = new ExBorder(graphic.borderTop);
41 | this.borderBottom = new ExBorder(graphic.borderBottom);
42 | this.borderRight = new ExBorder(graphic.borderRight);
43 | this.borderLeft = new ExBorder(graphic.borderLeft);
44 | this.borderInside = new ExBorder(graphic.borderInside);
45 | this.borderOutside = new ExBorder(graphic.borderOutside);
46 |
47 | this.fillColor = graphic.fillColor;
48 |
49 | this.active = graphic.active;
50 | }
51 |
52 | public ExGraphic(XL.IXLStyle style, XL.IXLWorkbook workbook)
53 | {
54 | this.borderTop = new ExBorder(style.Border.TopBorder, style.Border.TopBorderColor, workbook);
55 | this.borderBottom = new ExBorder(style.Border.BottomBorder, style.Border.BottomBorderColor, workbook);
56 | this.borderRight = new ExBorder(style.Border.RightBorder, style.Border.RightBorderColor, workbook);
57 | this.borderLeft = new ExBorder(style.Border.LeftBorder, style.Border.LeftBorderColor, workbook);
58 |
59 | this.fillColor = style.Fill.BackgroundColor.ToColor(workbook);
60 | this.active = true;
61 | }
62 |
63 | #endregion
64 |
65 | #region properties
66 |
67 | public virtual bool Active
68 | {
69 | get
70 | {
71 | if (active) return true;
72 | if (borderTop.Active) return true;
73 | if (borderBottom.Active) return true;
74 | if (borderRight.Active) return true;
75 | if (borderLeft.Active) return true;
76 | if (borderInside.Active) return true;
77 | if (borderOutside.Active) return true;
78 | return false;
79 | }
80 | }
81 |
82 | public virtual ExBorder BorderTop
83 | {
84 | get { return new ExBorder(this.borderTop); }
85 | set { this.borderTop = value; }
86 | }
87 |
88 | public virtual ExBorder BorderBottom
89 | {
90 | get { return new ExBorder(this.borderBottom); }
91 | set { this.borderBottom = value; }
92 | }
93 |
94 | public virtual ExBorder BorderLeft
95 | {
96 | get { return new ExBorder(this.borderLeft); }
97 | set { this.borderLeft = value; }
98 | }
99 |
100 | public virtual ExBorder BorderRight
101 | {
102 | get { return new ExBorder(this.borderRight); }
103 | set { this.borderRight = value; }
104 | }
105 |
106 | public virtual ExBorder BorderOutside
107 | {
108 | get { return new ExBorder(this.borderOutside); }
109 | set { this.borderOutside = value; }
110 | }
111 |
112 | public virtual ExBorder BorderInside
113 | {
114 | get { return new ExBorder(this.borderInside); }
115 | set { this.borderInside = value; }
116 | }
117 |
118 | public virtual Sd.Color FillColor
119 | {
120 | get { return this.fillColor; }
121 | set { this.fillColor = value; this.active = true; }
122 | }
123 |
124 | public virtual bool HasFillColor
125 | {
126 | get { return this.fillColor != Sd.Color.Transparent; }
127 | }
128 |
129 | #endregion
130 |
131 | #region methods
132 |
133 | public void Apply(XL.IXLStyle input)
134 | {
135 | if (this.Active)
136 | {
137 | if (this.HasFillColor) input.Fill.SetBackgroundColor(this.FillColor.ToExcel());
138 |
139 | if (this.BorderBottom.Active)
140 | {
141 | input.Border.SetBottomBorder(this.BorderBottom.LineType.ToExcel());
142 | input.Border.SetBottomBorderColor(this.BorderBottom.Color.ToExcel());
143 | }
144 |
145 | if (this.BorderTop.Active)
146 | {
147 | input.Border.SetTopBorder(this.BorderTop.LineType.ToExcel());
148 | input.Border.SetTopBorderColor(this.BorderTop.Color.ToExcel());
149 | }
150 |
151 | if (this.BorderLeft.Active)
152 | {
153 | input.Border.SetLeftBorder(this.BorderLeft.LineType.ToExcel());
154 | input.Border.SetLeftBorderColor(this.BorderLeft.Color.ToExcel());
155 | }
156 |
157 | if (this.BorderRight.Active)
158 | {
159 | input.Border.SetRightBorder(this.BorderRight.LineType.ToExcel());
160 | input.Border.SetRightBorderColor(this.BorderRight.Color.ToExcel());
161 | }
162 |
163 | if (this.BorderInside.Active)
164 | {
165 | input.Border.SetInsideBorder(this.BorderInside.LineType.ToExcel());
166 | input.Border.SetInsideBorderColor(this.BorderInside.Color.ToExcel());
167 | }
168 |
169 | if (this.BorderOutside.Active)
170 | {
171 | input.Border.SetOutsideBorder(this.BorderOutside.LineType.ToExcel());
172 | input.Border.SetOutsideBorderColor(this.BorderOutside.Color.ToExcel());
173 | }
174 | }
175 | }
176 |
177 | #endregion
178 |
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/ExcelPlus/Classes/ExSpark.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | using Sd = System.Drawing;
8 |
9 | namespace ExcelPlus
10 | {
11 | public class ExSpark
12 | {
13 | #region members
14 |
15 | protected ExRange location = new ExRange();
16 | protected ExRange range = new ExRange();
17 |
18 | protected Sd.Color color = Constants.StartColor;
19 | protected double weight = 1.0;
20 |
21 | protected bool isColumn = false;
22 |
23 | #endregion
24 |
25 | #region constructors
26 |
27 | public ExSpark()
28 | {
29 | }
30 |
31 | public ExSpark(ExSpark spark)
32 | {
33 | this.range = spark.Range;
34 | this.location = spark.Location;
35 |
36 | this.color = spark.color;
37 | this.weight = spark.weight;
38 | this.isColumn = spark.isColumn;
39 | }
40 |
41 | public static ExSpark ConstructLine(ExRange location, ExRange range, Sd.Color color, double weight)
42 | {
43 | ExSpark spark = new ExSpark();
44 |
45 | spark.Location = location;
46 | spark.Range = range;
47 | spark.color = color;
48 | spark.weight = weight;
49 | spark.isColumn = false;
50 |
51 | return spark;
52 | }
53 |
54 | public static ExSpark ConstructBar(ExRange location, ExRange range, Sd.Color color, double weight)
55 | {
56 | ExSpark spark = new ExSpark();
57 |
58 | spark.Location = location;
59 | spark.Range = range;
60 | spark.color = color;
61 | spark.weight = weight;
62 | spark.isColumn = true;
63 |
64 | return spark;
65 | }
66 |
67 | #endregion
68 |
69 | #region properties
70 |
71 | public virtual ExRange Location
72 | {
73 | get { return new ExRange(this.location); }
74 | set { this.location = new ExRange(value); }
75 | }
76 |
77 | public virtual ExRange Range
78 | {
79 | get { return new ExRange(this.range); }
80 | set { this.range = new ExRange(value); }
81 | }
82 |
83 | public virtual Sd.Color Color
84 | {
85 | get { return this.color; }
86 | set { this.color = value; }
87 | }
88 |
89 | public virtual double Weight
90 | {
91 | get { return this.weight; }
92 | set { this.weight = value; }
93 | }
94 |
95 | public virtual bool IsColumn
96 | {
97 | get { return this.isColumn; }
98 | set { this.isColumn = value; }
99 | }
100 |
101 | #endregion
102 |
103 | #region methods
104 |
105 |
106 |
107 | #endregion
108 |
109 |
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con_Bar.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Sd = System.Drawing;
8 |
9 | namespace ExcelPlus.Components.Analysis
10 | {
11 | public class GH_XL_Con_Bar : GH_XL_Con__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_XL_Con_Bar class.
15 | ///
16 | public GH_XL_Con_Bar()
17 | : base("Conditional Bar", "Con Bar",
18 | "Applies value scale conditional formatting to a range",
19 | Constants.ShortName, Constants.SubAnalysis)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.secondary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager.AddColourParameter("Color", "C", "The bar color", GH_ParamAccess.item, Constants.StartColor);
38 | pManager[1].Optional = true;
39 | }
40 |
41 | ///
42 | /// Registers all the output parameters for this component.
43 | ///
44 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
45 | {
46 | base.RegisterOutputParams(pManager);
47 | }
48 |
49 | ///
50 | /// This is the method that actually does the work.
51 | ///
52 | /// The DA object is used to retrieve from inputs and store in outputs.
53 | protected override void SolveInstance(IGH_DataAccess DA)
54 | {
55 | IGH_Goo goo = null;
56 | if (!DA.GetData(0, ref goo)) return;
57 |
58 | Sd.Color color1 = Constants.StartColor;
59 | DA.GetData(1, ref color1);
60 |
61 | //Sd.Color color2 = Constants.MidColor;
62 | //bool toggle = DA.GetData(2, ref color2);
63 |
64 | ExCondition condition = ExCondition.CreateBarCondition(color1);
65 |
66 | //if (toggle)
67 | //{
68 | // condition = ExCondition.CreateBarCondition(color1, color2);
69 | //}
70 | //else
71 | //{
72 | // condition = ExCondition.CreateBarCondition(color1);
73 | //}
74 |
75 | if (goo.CastTo(out ExRange range))
76 | {
77 | range = new ExRange(range);
78 | range.AddConditions(condition);
79 | DA.SetData(0, range);
80 | }
81 | else if (goo.CastTo(out ExWorksheet sheet))
82 | {
83 | sheet = new ExWorksheet(sheet);
84 | sheet.AddConditions(condition);
85 | DA.SetData(0, sheet);
86 | }
87 |
88 | }
89 |
90 | ///
91 | /// Provides an Icon for the component.
92 | ///
93 | protected override System.Drawing.Bitmap Icon
94 | {
95 | get
96 | {
97 | //You can add image files to your project resources and access them like this:
98 | // return Resources.IconForThisComponent;
99 | return Properties.Resources.XL_Con_Bars;
100 | }
101 | }
102 |
103 | ///
104 | /// Gets the unique ID for this component. Do not change this ID after release.
105 | ///
106 | public override Guid ComponentGuid
107 | {
108 | get { return new Guid("4c9af0af-af94-43f6-a932-84b8853d3745"); }
109 | }
110 | }
111 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con_Between.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Sd = System.Drawing;
8 |
9 | namespace ExcelPlus.Components.Analysis
10 | {
11 | public class GH_XL_Con_Between : GH_XL_Con__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_XL_Con_Between class.
15 | ///
16 | public GH_XL_Con_Between()
17 | : base("Conditional Between", "Con Btw",
18 | "Applies conditional formatting for values inside a bounds to a range",
19 | Constants.ShortName, Constants.SubAnalysis)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.secondary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager.AddIntervalParameter("Domain", "D", "The domain to evaluate", GH_ParamAccess.item);
38 | pManager.AddBooleanParameter("Flip", "F", "If true, non-unique values will be highlighted", GH_ParamAccess.item, false);
39 | pManager[2].Optional = true;
40 | pManager.AddColourParameter("Cell Color", "C", "The cell highlight color", GH_ParamAccess.item, Constants.StartColor);
41 | pManager[3].Optional = true;
42 | }
43 |
44 | ///
45 | /// Registers all the output parameters for this component.
46 | ///
47 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
48 | {
49 | base.RegisterOutputParams(pManager);
50 | }
51 |
52 | ///
53 | /// This is the method that actually does the work.
54 | ///
55 | /// The DA object is used to retrieve from inputs and store in outputs.
56 | protected override void SolveInstance(IGH_DataAccess DA)
57 | {
58 | IGH_Goo goo = null;
59 | if (!DA.GetData(0, ref goo)) return;
60 |
61 | Interval domain = new Interval(0,1);
62 | DA.GetData(1, ref domain);
63 |
64 | bool flip = false;
65 | DA.GetData(2, ref flip);
66 |
67 | Sd.Color color1 = Constants.StartColor;
68 | DA.GetData(3, ref color1);
69 |
70 | ExCondition condition =ExCondition.CreateBetweenCondition(domain.Min,domain.Max,flip,color1);
71 |
72 | if (goo.CastTo(out ExRange range))
73 | {
74 | range = new ExRange(range);
75 | range.AddConditions(condition);
76 | DA.SetData(0, range);
77 | }
78 | else if (goo.CastTo(out ExWorksheet sheet))
79 | {
80 | sheet = new ExWorksheet(sheet);
81 | sheet.AddConditions(condition);
82 | DA.SetData(0, sheet);
83 | }
84 |
85 | }
86 |
87 | ///
88 | /// Provides an Icon for the component.
89 | ///
90 | protected override System.Drawing.Bitmap Icon
91 | {
92 | get
93 | {
94 | //You can add image files to your project resources and access them like this:
95 | // return Resources.IconForThisComponent;
96 | return Properties.Resources.XL_Con_Between;
97 | }
98 | }
99 |
100 | ///
101 | /// Gets the unique ID for this component. Do not change this ID after release.
102 | ///
103 | public override Guid ComponentGuid
104 | {
105 | get { return new Guid("c7cc1156-2cc3-42a6-a631-0e7196a88656"); }
106 | }
107 | }
108 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con_Blank.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Sd = System.Drawing;
8 |
9 | namespace ExcelPlus.Components.Analysis
10 | {
11 | public class GH_XL_Con_Blank : GH_XL_Con__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_XL_Con_Blank class.
15 | ///
16 | public GH_XL_Con_Blank()
17 | : base("Conditional Blank", "Con Blank",
18 | "Applies conditional formatting to blank cells inside a Range",
19 | Constants.ShortName, Constants.SubAnalysis)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.secondary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager.AddBooleanParameter("Flip", "F", "If true, non blank cells will be highlighted", GH_ParamAccess.item, false);
38 | pManager[1].Optional = true;
39 | pManager.AddColourParameter("Cell Color", "C", "The cell highlight color", GH_ParamAccess.item, Constants.StartColor);
40 | pManager[2].Optional = true;
41 | }
42 |
43 | ///
44 | /// Registers all the output parameters for this component.
45 | ///
46 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
47 | {
48 | base.RegisterOutputParams(pManager);
49 | }
50 |
51 | ///
52 | /// This is the method that actually does the work.
53 | ///
54 | /// The DA object is used to retrieve from inputs and store in outputs.
55 | protected override void SolveInstance(IGH_DataAccess DA)
56 | {
57 | IGH_Goo goo = null;
58 | if (!DA.GetData(0, ref goo)) return;
59 |
60 | bool flip = false;
61 | DA.GetData(1, ref flip);
62 |
63 | Sd.Color color1 = Constants.StartColor;
64 | DA.GetData(2, ref color1);
65 |
66 | ExCondition condition = ExCondition.CreateEmptyCondition(flip, color1);
67 |
68 | if (goo.CastTo(out ExRange range))
69 | {
70 | range = new ExRange(range);
71 | range.AddConditions(condition);
72 | DA.SetData(0, range);
73 | }
74 | else if (goo.CastTo(out ExWorksheet sheet))
75 | {
76 | sheet = new ExWorksheet(sheet);
77 | sheet.AddConditions(condition);
78 | DA.SetData(0, sheet);
79 | }
80 |
81 | }
82 |
83 | ///
84 | /// Provides an Icon for the component.
85 | ///
86 | protected override System.Drawing.Bitmap Icon
87 | {
88 | get
89 | {
90 | //You can add image files to your project resources and access them like this:
91 | // return Resources.IconForThisComponent;
92 | return Properties.Resources.XL_Con_Blank;
93 | }
94 | }
95 |
96 | ///
97 | /// Gets the unique ID for this component. Do not change this ID after release.
98 | ///
99 | public override Guid ComponentGuid
100 | {
101 | get { return new Guid("efc605db-1ff3-499c-aee3-42c3becd9aec"); }
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con_Percent.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Sd = System.Drawing;
8 |
9 | namespace ExcelPlus.Components
10 | {
11 | public class GH_XL_Con_Percent : GH_XL_Con__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_XL_Con_Percent class.
15 | ///
16 | public GH_XL_Con_Percent()
17 | : base("Conditional Percent", "Con Pert",
18 | "Applies top percent based conditional formatting to a range",
19 | Constants.ShortName, Constants.SubAnalysis)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.secondary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager.AddNumberParameter("Percentage", "P", "The unitized percentage of the values to highlight (0-1)", GH_ParamAccess.item, 0.5);
38 | pManager[1].Optional = true;
39 | pManager.AddBooleanParameter("Flip", "F", "If true, the bottom percent will be highlighted", GH_ParamAccess.item, false);
40 | pManager[2].Optional = true;
41 | pManager.AddColourParameter("Cell Color", "C", "The cell highlight color", GH_ParamAccess.item, Constants.StartColor);
42 | pManager[3].Optional = true;
43 | }
44 |
45 | ///
46 | /// Registers all the output parameters for this component.
47 | ///
48 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
49 | {
50 | base.RegisterOutputParams(pManager);
51 | }
52 |
53 | ///
54 | /// This is the method that actually does the work.
55 | ///
56 | /// The DA object is used to retrieve from inputs and store in outputs.
57 | protected override void SolveInstance(IGH_DataAccess DA)
58 | {
59 | IGH_Goo goo = null;
60 | if (!DA.GetData(0, ref goo)) return;
61 |
62 | double value = 0.5;
63 | DA.GetData(1, ref value);
64 |
65 | bool flip = false;
66 | DA.GetData(2, ref flip);
67 |
68 | Sd.Color color1 = Constants.StartColor;
69 | DA.GetData(3, ref color1);
70 |
71 | ExCondition condition = ExCondition.CreateTopPercentCondition(value,flip, color1);
72 |
73 | if (goo.CastTo(out ExRange range))
74 | {
75 | range = new ExRange(range);
76 | range.AddConditions(condition);
77 | DA.SetData(0, range);
78 | }
79 | else if (goo.CastTo(out ExWorksheet sheet))
80 | {
81 | sheet = new ExWorksheet(sheet);
82 | sheet.AddConditions(condition);
83 | DA.SetData(0, sheet);
84 | }
85 | }
86 |
87 | ///
88 | /// Provides an Icon for the component.
89 | ///
90 | protected override System.Drawing.Bitmap Icon
91 | {
92 | get
93 | {
94 | //You can add image files to your project resources and access them like this:
95 | // return Resources.IconForThisComponent;
96 | return Properties.Resources.XL_Con_Percent;
97 | }
98 | }
99 |
100 | ///
101 | /// Gets the unique ID for this component. Do not change this ID after release.
102 | ///
103 | public override Guid ComponentGuid
104 | {
105 | get { return new Guid("3938d528-227d-48d4-991e-86e36941f58e"); }
106 | }
107 | }
108 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con_Scale.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Sd = System.Drawing;
8 |
9 | namespace ExcelPlus.Components.Analysis
10 | {
11 | public class GH_XL_Con_Scale : GH_XL_Con__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_XL_Con_Scale class.
15 | ///
16 | public GH_XL_Con_Scale()
17 | : base("Conditional Scale", "Con Scl",
18 | "Applies value scale conditional formatting to a range",
19 | Constants.ShortName, Constants.SubAnalysis)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.secondary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager.AddNumberParameter("Parameter", "P", "The parameter of the midpoint of a 3 color gradient", GH_ParamAccess.item, 0.5);
38 | pManager[1].Optional = true;
39 | pManager.AddColourParameter("Gradient Color 1", "C0", "The first color of the gradient", GH_ParamAccess.item, Constants.StartColor);
40 | pManager[2].Optional = true;
41 | pManager.AddColourParameter("Gradient Color 2", "C1", "The second color of the gradient", GH_ParamAccess.item, Constants.MidColor);
42 | pManager[3].Optional = true;
43 | pManager.AddColourParameter("Gradient Color 3", "C2", "The third color of the gradient", GH_ParamAccess.item);
44 | pManager[4].Optional = true;
45 | }
46 |
47 | ///
48 | /// Registers all the output parameters for this component.
49 | ///
50 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
51 | {
52 | base.RegisterOutputParams(pManager);
53 | }
54 |
55 | ///
56 | /// This is the method that actually does the work.
57 | ///
58 | /// The DA object is used to retrieve from inputs and store in outputs.
59 | protected override void SolveInstance(IGH_DataAccess DA)
60 | {
61 | IGH_Goo goo = null;
62 | if (!DA.GetData(0, ref goo)) return;
63 |
64 | double param = 0.5;
65 | DA.GetData(1, ref param);
66 |
67 | Sd.Color color1 = Constants.StartColor;
68 | DA.GetData(2, ref color1);
69 |
70 | Sd.Color color2 = Constants.MidColor;
71 | DA.GetData(3, ref color2);
72 |
73 | Sd.Color color3 = Constants.EndColor;
74 | bool hasMid = DA.GetData(4, ref color3);
75 |
76 | ExCondition condition = new ExCondition();
77 |
78 | if (hasMid)
79 | {
80 | condition = ExCondition.CreateScalarCondition(color1,color2,param,color3);
81 | }
82 | else
83 | {
84 | condition = ExCondition.CreateScalarCondition(color1,color2);
85 | }
86 |
87 | if (goo.CastTo(out ExRange range))
88 | {
89 | range = new ExRange(range);
90 | range.AddConditions(condition);
91 | DA.SetData(0, range);
92 | }
93 | else if (goo.CastTo(out ExWorksheet sheet))
94 | {
95 | sheet = new ExWorksheet(sheet);
96 | sheet.AddConditions(condition);
97 | DA.SetData(0, sheet);
98 | }
99 |
100 | }
101 |
102 | ///
103 | /// Provides an Icon for the component.
104 | ///
105 | protected override System.Drawing.Bitmap Icon
106 | {
107 | get
108 | {
109 | //You can add image files to your project resources and access them like this:
110 | // return Resources.IconForThisComponent;
111 | return Properties.Resources.XL_Con_Scale;
112 | }
113 | }
114 |
115 | ///
116 | /// Gets the unique ID for this component. Do not change this ID after release.
117 | ///
118 | public override Guid ComponentGuid
119 | {
120 | get { return new Guid("d6d6d342-1607-4f56-9282-4cd70b8892b7"); }
121 | }
122 | }
123 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con_SparkBar.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Sd = System.Drawing;
8 | namespace ExcelPlus.Components.Analysis
9 | {
10 | public class GH_XL_Con_SparkBar : GH_XL_Wks__Base
11 | {
12 | ///
13 | /// Initializes a new instance of the GH_XL_Con_SparkBar class.
14 | ///
15 | public GH_XL_Con_SparkBar()
16 | : base("Add Spark Bar", "SparkBar",
17 | "Adds a SparkBar to a Range",
18 | Constants.ShortName, Constants.SubAnalysis)
19 | {
20 | }
21 |
22 | ///
23 | /// Set Exposure level for the component.
24 | ///
25 | public override GH_Exposure Exposure
26 | {
27 | get { return GH_Exposure.primary; }
28 | }
29 |
30 | ///
31 | /// Registers all the input parameters for this component.
32 | ///
33 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
34 | {
35 | base.RegisterInputParams(pManager);
36 | pManager.AddGenericParameter("Source Range", "Rng", Constants.Range.Input, GH_ParamAccess.item);
37 | pManager.AddGenericParameter("Location Range", "L", Constants.Range.Input, GH_ParamAccess.item);
38 | pManager.AddColourParameter("Color", "C", "The Spark Bar color", GH_ParamAccess.item, Constants.StartColor);
39 | pManager[3].Optional = true;
40 | pManager.AddNumberParameter("Weight", "W", "The Spark Bar weight", GH_ParamAccess.item, 1.0);
41 | pManager[4].Optional = true;
42 | }
43 |
44 | ///
45 | /// Registers all the output parameters for this component.
46 | ///
47 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
48 | {
49 | base.RegisterOutputParams(pManager);
50 | }
51 |
52 | ///
53 | /// This is the method that actually does the work.
54 | ///
55 | /// The DA object is used to retrieve from inputs and store in outputs.
56 | protected override void SolveInstance(IGH_DataAccess DA)
57 | {
58 | IGH_Goo gooS = null;
59 | DA.GetData(0, ref gooS);
60 | if (!gooS.TryGetWorksheet(out ExWorksheet worksheet)) return;
61 |
62 | IGH_Goo gooR = null;
63 | DA.GetData(1, ref gooR);
64 | if (!gooR.TryGetRange(out ExRange range)) return;
65 |
66 | IGH_Goo gooL = null;
67 | DA.GetData(2, ref gooL);
68 | if (!gooL.TryGetRange(out ExRange location)) return;
69 |
70 | Sd.Color color = Constants.StartColor;
71 | DA.GetData(3, ref color);
72 |
73 | double weight = 1.0;
74 | DA.GetData(4, ref weight);
75 |
76 | worksheet.AddSparkLines(ExSpark.ConstructBar(location, range, color, weight));
77 |
78 | DA.SetData(0, worksheet);
79 | }
80 |
81 | ///
82 | /// Provides an Icon for the component.
83 | ///
84 | protected override System.Drawing.Bitmap Icon
85 | {
86 | get
87 | {
88 | //You can add image files to your project resources and access them like this:
89 | // return Resources.IconForThisComponent;
90 | return Properties.Resources.XL_Con_SparkBar;
91 | }
92 | }
93 |
94 | ///
95 | /// Gets the unique ID for this component. Do not change this ID after release.
96 | ///
97 | public override Guid ComponentGuid
98 | {
99 | get { return new Guid("3a8eb5e0-4c99-4080-b1db-5434a670f0bb"); }
100 | }
101 | }
102 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con_SparkLine.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Sd = System.Drawing;
8 |
9 | namespace ExcelPlus.Components
10 | {
11 | public class GH_XL_Con_SparkLine : GH_XL_Wks__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_XL_Con_SparkLine class.
15 | ///
16 | public GH_XL_Con_SparkLine()
17 | : base("Add Spark Line", "SparkLine",
18 | "Adds a Sparkline to a Range",
19 | Constants.ShortName, Constants.SubAnalysis)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.primary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager.AddGenericParameter("Source Range", "Rng", Constants.Range.Input, GH_ParamAccess.item);
38 | pManager.AddGenericParameter("Location Range", "L", Constants.Range.Input, GH_ParamAccess.item);
39 | pManager.AddColourParameter("Color", "C", "The SparkLine color", GH_ParamAccess.item, Constants.StartColor);
40 | pManager[3].Optional = true;
41 | pManager.AddNumberParameter("Weight", "W", "The SparkLine weight", GH_ParamAccess.item, 1.0);
42 | pManager[4].Optional = true;
43 | }
44 |
45 | ///
46 | /// Registers all the output parameters for this component.
47 | ///
48 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
49 | {
50 | base.RegisterOutputParams(pManager);
51 | }
52 |
53 | ///
54 | /// This is the method that actually does the work.
55 | ///
56 | /// The DA object is used to retrieve from inputs and store in outputs.
57 | protected override void SolveInstance(IGH_DataAccess DA)
58 | {
59 | IGH_Goo gooS = null;
60 | DA.GetData(0, ref gooS);
61 | if (!gooS.TryGetWorksheet(out ExWorksheet worksheet)) return;
62 |
63 | IGH_Goo gooR = null;
64 | DA.GetData(1, ref gooR);
65 | if (!gooR.TryGetRange(out ExRange range)) return;
66 |
67 | IGH_Goo gooL = null;
68 | DA.GetData(2, ref gooL);
69 | if (!gooL.TryGetRange(out ExRange location)) return;
70 |
71 | Sd.Color color = Constants.StartColor;
72 | DA.GetData(3, ref color);
73 |
74 | double weight = 1.0;
75 | DA.GetData(4, ref weight);
76 |
77 | worksheet.AddSparkLines(ExSpark.ConstructLine(location, range, color, weight));
78 |
79 | DA.SetData(0, worksheet);
80 | }
81 |
82 | ///
83 | /// Provides an Icon for the component.
84 | ///
85 | protected override System.Drawing.Bitmap Icon
86 | {
87 | get
88 | {
89 | //You can add image files to your project resources and access them like this:
90 | // return Resources.IconForThisComponent;
91 | return Properties.Resources.XL_Con_SparkLine;
92 | }
93 | }
94 |
95 | ///
96 | /// Gets the unique ID for this component. Do not change this ID after release.
97 | ///
98 | public override Guid ComponentGuid
99 | {
100 | get { return new Guid("27ff89a9-af7b-4b94-80b9-efbbda0244b8"); }
101 | }
102 | }
103 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con_Text.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Parameters;
3 | using Grasshopper.Kernel.Types;
4 | using Rhino.Geometry;
5 | using System;
6 | using System.Collections.Generic;
7 |
8 | using Sd = System.Drawing;
9 |
10 | namespace ExcelPlus.Components.Analysis
11 | {
12 | public class GH_XL_Con_Text : GH_XL_Con__Base
13 | {
14 | ///
15 | /// Initializes a new instance of the GH_XL_Con_Average class.
16 | ///
17 | public GH_XL_Con_Text()
18 | : base("Conditional Text", "Con Txt",
19 | "Applies text (string) based conditional formatting to a range",
20 | Constants.ShortName, Constants.SubAnalysis)
21 | {
22 | }
23 |
24 | ///
25 | /// Set Exposure level for the component.
26 | ///
27 | public override GH_Exposure Exposure
28 | {
29 | get { return GH_Exposure.secondary; }
30 | }
31 |
32 | ///
33 | /// Registers all the input parameters for this component.
34 | ///
35 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
36 | {
37 | base.RegisterInputParams(pManager);
38 | pManager.AddTextParameter("Value", "V", "The text to check against", GH_ParamAccess.item);
39 | pManager.AddIntegerParameter("Type", "T", "The condition type", GH_ParamAccess.item, 0);
40 | pManager[2].Optional = true;
41 | pManager.AddColourParameter("Cell Color", "C", "The cell highlight color", GH_ParamAccess.item, Constants.StartColor);
42 | pManager[3].Optional = true;
43 |
44 | Param_Integer paramA = (Param_Integer)pManager[2];
45 | foreach (TextCondition value in Enum.GetValues(typeof(TextCondition)))
46 | {
47 | paramA.AddNamedValue(value.ToString(), (int)value);
48 | }
49 | }
50 |
51 | ///
52 | /// Registers all the output parameters for this component.
53 | ///
54 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
55 | {
56 | base.RegisterOutputParams(pManager);
57 | }
58 |
59 | ///
60 | /// This is the method that actually does the work.
61 | ///
62 | /// The DA object is used to retrieve from inputs and store in outputs.
63 | protected override void SolveInstance(IGH_DataAccess DA)
64 | {
65 | IGH_Goo goo = null;
66 | if (!DA.GetData(0, ref goo)) return;
67 |
68 | string value = "A";
69 | DA.GetData(1, ref value);
70 |
71 | int type = 0;
72 | DA.GetData(2, ref type);
73 |
74 | Sd.Color color1 = Constants.StartColor;
75 | DA.GetData(3, ref color1);
76 |
77 | ExCondition condition = ExCondition.CreateTextCondition(value, (TextCondition)type, color1);
78 |
79 | if (goo.CastTo(out ExRange range))
80 | {
81 | range = new ExRange(range);
82 | range.AddConditions(condition);
83 | DA.SetData(0, range);
84 | }
85 | else if (goo.CastTo(out ExWorksheet sheet))
86 | {
87 | sheet = new ExWorksheet(sheet);
88 | sheet.AddConditions(condition);
89 | DA.SetData(0, sheet);
90 | }
91 |
92 | }
93 |
94 | ///
95 | /// Provides an Icon for the component.
96 | ///
97 | protected override System.Drawing.Bitmap Icon
98 | {
99 | get
100 | {
101 | //You can add image files to your project resources and access them like this:
102 | // return Resources.IconForThisComponent;
103 | return Properties.Resources.XL_Con_Text;
104 | }
105 | }
106 |
107 | ///
108 | /// Gets the unique ID for this component. Do not change this ID after release.
109 | ///
110 | public override Guid ComponentGuid
111 | {
112 | get { return new Guid("4fb9378f-2e3a-4f2d-9834-73930ba5d57b"); }
113 | }
114 | }
115 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con_Top.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Sd = System.Drawing;
8 |
9 | namespace ExcelPlus.Components.Analysis
10 | {
11 | public class GH_XL_Con_Top : GH_XL_Con__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_XL_Con_Top class.
15 | ///
16 | public GH_XL_Con_Top()
17 | : base("Conditional Top", "Con Top",
18 | "Applies top percent based conditional formatting to a Range",
19 | Constants.ShortName, Constants.SubAnalysis)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.secondary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager.AddIntegerParameter("Total", "T", "The total number of values to highlight", GH_ParamAccess.item, 10);
38 | pManager[1].Optional = true;
39 | pManager.AddBooleanParameter("Flip", "F", "If true, the bottom percent will be highlighted", GH_ParamAccess.item, false);
40 | pManager[2].Optional = true;
41 | pManager.AddColourParameter("Cell Color", "C", "The cell highlight color", GH_ParamAccess.item, Constants.StartColor);
42 | pManager[3].Optional = true;
43 | }
44 |
45 | ///
46 | /// Registers all the output parameters for this component.
47 | ///
48 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
49 | {
50 | base.RegisterOutputParams(pManager);
51 | }
52 |
53 | ///
54 | /// This is the method that actually does the work.
55 | ///
56 | /// The DA object is used to retrieve from inputs and store in outputs.
57 | protected override void SolveInstance(IGH_DataAccess DA)
58 | {
59 | IGH_Goo goo = null;
60 | if (!DA.GetData(0, ref goo)) return;
61 |
62 | int value = 0;
63 | DA.GetData(1, ref value);
64 |
65 | bool flip = false;
66 | DA.GetData(2, ref flip);
67 |
68 | Sd.Color color1 = Constants.StartColor;
69 | DA.GetData(3, ref color1);
70 |
71 | ExCondition condition = ExCondition.CreateTopCountCondition(value, flip, color1);
72 |
73 | if (goo.CastTo(out ExRange range))
74 | {
75 | range = new ExRange(range);
76 | range.AddConditions(condition);
77 | DA.SetData(0, range);
78 | }
79 | else if (goo.CastTo(out ExWorksheet sheet))
80 | {
81 | sheet = new ExWorksheet(sheet);
82 | sheet.AddConditions(condition);
83 | DA.SetData(0, sheet);
84 | }
85 |
86 | }
87 |
88 | ///
89 | /// Provides an Icon for the component.
90 | ///
91 | protected override System.Drawing.Bitmap Icon
92 | {
93 | get
94 | {
95 | //You can add image files to your project resources and access them like this:
96 | // return Resources.IconForThisComponent;
97 | return Properties.Resources.XL_Con_Count;
98 | }
99 | }
100 |
101 | ///
102 | /// Gets the unique ID for this component. Do not change this ID after release.
103 | ///
104 | public override Guid ComponentGuid
105 | {
106 | get { return new Guid("9dc0b177-0feb-4f72-937e-205e5085dfc4"); }
107 | }
108 | }
109 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con_Unique.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Sd = System.Drawing;
8 |
9 | namespace ExcelPlus.Components.Analysis
10 | {
11 | public class GH_XL_Con_Unique : GH_XL_Con__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_XL_Con_Unique class.
15 | ///
16 | public GH_XL_Con_Unique()
17 | : base("Conditional Unique", "Con Uni",
18 | "Applies unique value conditional formatting to a range",
19 | Constants.ShortName, Constants.SubAnalysis)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.secondary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager.AddBooleanParameter("Flip", "F", "If true, non unique values will be highlighted", GH_ParamAccess.item, false);
38 | pManager[1].Optional = true;
39 | pManager.AddColourParameter("Cell Color", "C", "The cell highlight color", GH_ParamAccess.item, Constants.StartColor);
40 | pManager[2].Optional = true;
41 | }
42 |
43 | ///
44 | /// Registers all the output parameters for this component.
45 | ///
46 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
47 | {
48 | base.RegisterOutputParams(pManager);
49 | }
50 |
51 | ///
52 | /// This is the method that actually does the work.
53 | ///
54 | /// The DA object is used to retrieve from inputs and store in outputs.
55 | protected override void SolveInstance(IGH_DataAccess DA)
56 | {
57 | IGH_Goo goo = null;
58 | if (!DA.GetData(0, ref goo)) return;
59 |
60 | bool flip = false;
61 | DA.GetData(1, ref flip);
62 |
63 | Sd.Color color1 = Constants.StartColor;
64 | DA.GetData(2, ref color1);
65 |
66 | ExCondition condition = ExCondition.CreateUniqueCondition(flip, color1);
67 |
68 | if (goo.CastTo(out ExRange range))
69 | {
70 | range = new ExRange(range);
71 | range.AddConditions(condition);
72 | DA.SetData(0, range);
73 | }
74 | else if (goo.CastTo(out ExWorksheet sheet))
75 | {
76 | sheet = new ExWorksheet(sheet);
77 | sheet.AddConditions(condition);
78 | DA.SetData(0, sheet);
79 | }
80 |
81 | }
82 |
83 | ///
84 | /// Provides an Icon for the component.
85 | ///
86 | protected override System.Drawing.Bitmap Icon
87 | {
88 | get
89 | {
90 | //You can add image files to your project resources and access them like this:
91 | // return Resources.IconForThisComponent;
92 | return Properties.Resources.XL_Con_Unique;
93 | }
94 | }
95 |
96 | ///
97 | /// Gets the unique ID for this component. Do not change this ID after release.
98 | ///
99 | public override Guid ComponentGuid
100 | {
101 | get { return new Guid("7c546c23-fe54-471e-89ab-0fadab8d5879"); }
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con_Value.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Parameters;
3 | using Grasshopper.Kernel.Types;
4 | using Rhino.Geometry;
5 | using System;
6 | using System.Collections.Generic;
7 |
8 | using Sd = System.Drawing;
9 |
10 | namespace ExcelPlus.Components
11 | {
12 | public class GH_XL_Con_Value : GH_XL_Con__Base
13 | {
14 | ///
15 | /// Initializes a new instance of the GH_XL_Con_Value class.
16 | ///
17 | public GH_XL_Con_Value()
18 | : base("Conditional Value", "Con Val",
19 | "Applies value based conditional formatting to a range",
20 | Constants.ShortName, Constants.SubAnalysis)
21 | {
22 | }
23 |
24 | ///
25 | /// Set Exposure level for the component.
26 | ///
27 | public override GH_Exposure Exposure
28 | {
29 | get { return GH_Exposure.secondary; }
30 | }
31 |
32 | ///
33 | /// Registers all the input parameters for this component.
34 | ///
35 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
36 | {
37 | base.RegisterInputParams(pManager);
38 | pManager.AddNumberParameter("Value", "V", "The value to check against", GH_ParamAccess.item);
39 | pManager.AddIntegerParameter("Type", "T", "The condition type", GH_ParamAccess.item, 0);
40 | pManager[2].Optional = true;
41 | pManager.AddColourParameter("Cell Color", "C", "The cell highlight color", GH_ParamAccess.item, Constants.StartColor);
42 | pManager[3].Optional = true;
43 |
44 | Param_Integer paramA = (Param_Integer)pManager[2];
45 | foreach (ValueCondition value in Enum.GetValues(typeof(ValueCondition)))
46 | {
47 | paramA.AddNamedValue(value.ToString(), (int)value);
48 | }
49 | }
50 |
51 | ///
52 | /// Registers all the output parameters for this component.
53 | ///
54 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
55 | {
56 | base.RegisterOutputParams(pManager);
57 | }
58 |
59 | ///
60 | /// This is the method that actually does the work.
61 | ///
62 | /// The DA object is used to retrieve from inputs and store in outputs.
63 | protected override void SolveInstance(IGH_DataAccess DA)
64 | {
65 | IGH_Goo goo = null;
66 | if (!DA.GetData(0, ref goo)) return;
67 |
68 | double value = 0.5;
69 | DA.GetData(1, ref value);
70 |
71 | int type = 0;
72 | DA.GetData(2, ref type);
73 |
74 | Sd.Color color1 = Constants.StartColor;
75 | DA.GetData(3, ref color1);
76 |
77 | ExCondition condition = ExCondition.CreateValueCondition(value, (ValueCondition)type, color1);
78 |
79 | if (goo.CastTo(out ExRange range))
80 | {
81 | range = new ExRange(range);
82 | range.AddConditions(condition);
83 | DA.SetData(0, range);
84 | }
85 | else if (goo.CastTo(out ExWorksheet sheet))
86 | {
87 | sheet = new ExWorksheet(sheet);
88 | sheet.AddConditions(condition);
89 | DA.SetData(0, sheet);
90 | }
91 |
92 | }
93 |
94 | ///
95 | /// Provides an Icon for the component.
96 | ///
97 | protected override System.Drawing.Bitmap Icon
98 | {
99 | get
100 | {
101 | //You can add image files to your project resources and access them like this:
102 | // return Resources.IconForThisComponent;
103 | return Properties.Resources.XL_Con_Value;
104 | }
105 | }
106 |
107 | ///
108 | /// Gets the unique ID for this component. Do not change this ID after release.
109 | ///
110 | public override Guid ComponentGuid
111 | {
112 | get { return new Guid("be981ea3-33b4-4b78-8815-c2202c223f4f"); }
113 | }
114 | }
115 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Analysis/GH_XL_Con__Base.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Rhino.Geometry;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace ExcelPlus.Components
7 | {
8 | public abstract class GH_XL_Con__Base : GH_Component
9 | {
10 | ///
11 | /// Initializes a new instance of the GH_XL_Con__Base class.
12 | ///
13 | public GH_XL_Con__Base()
14 | : base("GH_XL_Con__Base", "Nickname",
15 | "Description",
16 | "Category", "Subcategory")
17 | {
18 | }
19 |
20 | public GH_XL_Con__Base(string Name, string NickName, string Description, string Category, string Subcategory) : base(Name, NickName, Description, Category, Subcategory)
21 | {
22 | }
23 |
24 | ///
25 | /// Registers all the input parameters for this component.
26 | ///
27 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
28 | {
29 | pManager.AddGenericParameter("Object", "Obj", "A Range, Worksheet, or Workbook Object", GH_ParamAccess.item);
30 | }
31 |
32 | ///
33 | /// Registers all the output parameters for this component.
34 | ///
35 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
36 | {
37 | pManager.AddGenericParameter("Object", "Obj", "A Cell, Range, Worksheet, or Workbook Object", GH_ParamAccess.item);
38 | }
39 |
40 | ///
41 | /// This is the method that actually does the work.
42 | ///
43 | /// The DA object is used to retrieve from inputs and store in outputs.
44 | protected override void SolveInstance(IGH_DataAccess DA)
45 | {
46 | }
47 |
48 | ///
49 | /// Provides an Icon for the component.
50 | ///
51 | protected override System.Drawing.Bitmap Icon
52 | {
53 | get
54 | {
55 | //You can add image files to your project resources and access them like this:
56 | // return Resources.IconForThisComponent;
57 | return null;
58 | }
59 | }
60 |
61 | ///
62 | /// Gets the unique ID for this component. Do not change this ID after release.
63 | ///
64 | public override Guid ComponentGuid
65 | {
66 | get { return new Guid("daf7808d-0023-470c-ac3b-27c7d9b7c5a2"); }
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Cell/GH_XL_Cel_Address.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Cell
8 | {
9 | public class GH_XL_Cel_Address : GH_XL_Cel__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Cel_Address class.
13 | ///
14 | public GH_XL_Cel_Address()
15 | : base("Cell Address", "Cell Addr",
16 | "Gets or Sets a Cell's Address",
17 | Constants.ShortName, Constants.SubCell)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.secondary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | pManager[0].Optional = true;
36 | pManager.AddTextParameter("Address", "A", "The Cell address", GH_ParamAccess.item);
37 | pManager[1].Optional = true;
38 |
39 | }
40 |
41 | ///
42 | /// Registers all the output parameters for this component.
43 | ///
44 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
45 | {
46 | base.RegisterOutputParams(pManager);
47 | pManager.AddTextParameter("Address", "A", "The Cell address", GH_ParamAccess.item);
48 | }
49 |
50 | ///
51 | /// This is the method that actually does the work.
52 | ///
53 | /// The DA object is used to retrieve from inputs and store in outputs.
54 | protected override void SolveInstance(IGH_DataAccess DA)
55 | {
56 | IGH_Goo gooC = null;
57 | DA.GetData(0, ref gooC);
58 | gooC.TryGetCell(out ExCell cell);
59 |
60 | string address = string.Empty;
61 | if (DA.GetData(1, ref address)) cell.Address = address;
62 |
63 | DA.SetData(0, cell);
64 | DA.SetData(1, cell.Address);
65 | }
66 |
67 | ///
68 | /// Provides an Icon for the component.
69 | ///
70 | protected override System.Drawing.Bitmap Icon
71 | {
72 | get
73 | {
74 | //You can add image files to your project resources and access them like this:
75 | // return Resources.IconForThisComponent;
76 | return Properties.Resources.XL_Cel_Address;
77 | }
78 | }
79 |
80 | ///
81 | /// Gets the unique ID for this component. Do not change this ID after release.
82 | ///
83 | public override Guid ComponentGuid
84 | {
85 | get { return new Guid("7462ed50-1b73-48a8-8fa9-41ad4b829e13"); }
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Cell/GH_XL_Cel_Cells.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Cell
8 | {
9 | public class GH_XL_Cel_Cells : GH_XL_Con__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Cel_Cells class.
13 | ///
14 | public GH_XL_Cel_Cells()
15 | : base("Generate Cells", "Cells",
16 | "Generates a list of Cells from a minimum Cell and maximum Cell",
17 | Constants.ShortName, Constants.SubCell)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.tertiary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | pManager.AddGenericParameter("Minimum Cell", "<", Constants.Cell.Input, GH_ParamAccess.item);
35 | pManager[0].Optional = true;
36 | pManager.AddGenericParameter("Maximum Cell", ">", Constants.Cell.Input, GH_ParamAccess.item);
37 | pManager[1].Optional = true;
38 | pManager.AddBooleanParameter("By Column", "C", "If true, Cells are listed by column. If false, by row", GH_ParamAccess.item, true);
39 | pManager[2].Optional = true;
40 | }
41 |
42 | ///
43 | /// Registers all the output parameters for this component.
44 | ///
45 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
46 | {
47 | pManager.AddGenericParameter(Constants.Cell.Name, Constants.Cell.NickName, Constants.Cell.Outputs, GH_ParamAccess.list);
48 | }
49 |
50 | ///
51 | /// This is the method that actually does the work.
52 | ///
53 | /// The DA object is used to retrieve from inputs and store in outputs.
54 | protected override void SolveInstance(IGH_DataAccess DA)
55 | {
56 | IGH_Goo gooA = null;
57 | DA.GetData(0, ref gooA);
58 | gooA.TryGetCell(out ExCell cellA);
59 |
60 | IGH_Goo gooB = null;
61 | DA.GetData(1, ref gooB);
62 | gooB.TryGetCell(out ExCell cellB);
63 |
64 | ExRange range = new ExRange(new List { cellA, cellB });
65 |
66 | bool flip = false;
67 | DA.GetData(2, ref flip);
68 |
69 | DA.SetDataList(0, range.Cells(flip));
70 | }
71 |
72 | ///
73 | /// Provides an Icon for the component.
74 | ///
75 | protected override System.Drawing.Bitmap Icon
76 | {
77 | get
78 | {
79 | //You can add image files to your project resources and access them like this:
80 | // return Resources.IconForThisComponent;
81 | return Properties.Resources.XL_Cel_GetCells2;
82 | }
83 | }
84 |
85 | ///
86 | /// Gets the unique ID for this component. Do not change this ID after release.
87 | ///
88 | public override Guid ComponentGuid
89 | {
90 | get { return new Guid("50fbdf6c-ca47-41eb-a577-a4de236d9c58"); }
91 | }
92 | }
93 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Cell/GH_XL_Cel_Construct.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components
8 | {
9 | public class GH_XL_Cel_Set : GH_XL_Cel__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Cel_Set class.
13 | ///
14 | public GH_XL_Cel_Set()
15 | : base("Cell Content", "Cell",
16 | "Gets or Sets the contents of a Cell",
17 | Constants.ShortName, Constants.SubCell)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.primary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | pManager[0].Optional = true;
36 | pManager.AddGenericParameter(Constants.Location.Name, "Optional " + Constants.Location.NickName, Constants.Location.Input, GH_ParamAccess.item);
37 | pManager[1].Optional = true;
38 | pManager.AddTextParameter("Value", "V", "Optional Cell value", GH_ParamAccess.item);
39 | pManager[2].Optional = true;
40 | pManager.AddTextParameter(Constants.Format.Name, "Optional "+Constants.Format.NickName, Constants.Format.Input, GH_ParamAccess.item);
41 | pManager[3].Optional = true;
42 | }
43 |
44 | ///
45 | /// Registers all the output parameters for this component.
46 | ///
47 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
48 | {
49 | base.RegisterOutputParams(pManager);
50 | pManager.AddPointParameter("Location", "L", "Cell location", GH_ParamAccess.item);
51 | ((IGH_PreviewObject)pManager[1]).Hidden = true;
52 | pManager.AddTextParameter("Value", "V", "Cell value", GH_ParamAccess.item);
53 | pManager.AddTextParameter("Format", "F", "Cell format", GH_ParamAccess.item);
54 | pManager.AddTextParameter("Formula", "=", "A cell formula if applicable", GH_ParamAccess.item);
55 | }
56 |
57 | ///
58 | /// This is the method that actually does the work.
59 | ///
60 | /// The DA object is used to retrieve from inputs and store in outputs.
61 | protected override void SolveInstance(IGH_DataAccess DA)
62 | {
63 | IGH_Goo gooC = null;
64 | DA.GetData(0, ref gooC);
65 | gooC.TryGetCell(out ExCell cell);
66 |
67 | IGH_Goo gooL = null;
68 | if (DA.GetData(1, ref gooL)) if (gooL.TryGetCell(out ExCell location)) cell.Address = location.Address;
69 |
70 | string value = string.Empty;
71 | if (DA.GetData(2, ref value)) cell.Value = value;
72 |
73 | string format = string.Empty;
74 | if (DA.GetData(3, ref format)) cell.Format = format;
75 |
76 | DA.SetData(0, new ExCell(cell));
77 | DA.SetData(1, new Point3d(cell.Column,cell.Row,0));
78 | DA.SetData(2, cell.Value);
79 | DA.SetData(3, cell.Format);
80 | DA.SetData(4, cell.Formula);
81 | }
82 |
83 | ///
84 | /// Provides an Icon for the component.
85 | ///
86 | protected override System.Drawing.Bitmap Icon
87 | {
88 | get
89 | {
90 | //You can add image files to your project resources and access them like this:
91 | // return Resources.IconForThisComponent;
92 | return Properties.Resources.XL_Cel_Construct;
93 | }
94 | }
95 |
96 | ///
97 | /// Gets the unique ID for this component. Do not change this ID after release.
98 | ///
99 | public override Guid ComponentGuid
100 | {
101 | get { return new Guid("2f33480d-1374-4bb5-a8fb-5959b369204b"); }
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Cell/GH_XL_Cel_Location.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Cell
8 | {
9 | public class GH_XL_Cel_Location : GH_XL_Cel__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Cel_Location class.
13 | ///
14 | public GH_XL_Cel_Location()
15 | : base("Cell Location", "Cell Loc",
16 | "Gets or Sets a Cell's Location",
17 | Constants.ShortName, Constants.SubCell)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.secondary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | pManager[0].Optional = true;
36 | pManager.AddIntegerParameter("Column", "C", "The Cell column index", GH_ParamAccess.item);
37 | pManager[1].Optional = true;
38 | pManager.AddIntegerParameter("Row", "R", "The Cell row index", GH_ParamAccess.item);
39 | pManager[2].Optional = true;
40 | pManager.AddBooleanParameter("Absolute Column", "AC", "Is the Cell column absolute", GH_ParamAccess.item);
41 | pManager[3].Optional = true;
42 | pManager.AddBooleanParameter("Absolute Row", "AR", "Is the Cell row absolute", GH_ParamAccess.item);
43 | pManager[4].Optional = true;
44 | }
45 |
46 | ///
47 | /// Registers all the output parameters for this component.
48 | ///
49 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
50 | {
51 | base.RegisterOutputParams(pManager);
52 | pManager.AddIntegerParameter("Column", "C", "The Cell Column index", GH_ParamAccess.item);
53 | pManager.AddIntegerParameter("Row", "R", "The Cell Row index", GH_ParamAccess.item);
54 | pManager.AddBooleanParameter("Absolute Column", "AC", "Is the Cell Column absolute", GH_ParamAccess.item);
55 | pManager.AddBooleanParameter("Absolute Row", "AR", "Is the Cell Row absolute", GH_ParamAccess.item);
56 | }
57 |
58 | ///
59 | /// This is the method that actually does the work.
60 | ///
61 | /// The DA object is used to retrieve from inputs and store in outputs.
62 | protected override void SolveInstance(IGH_DataAccess DA)
63 | {
64 | IGH_Goo gooC = null;
65 | DA.GetData(0, ref gooC);
66 | gooC.TryGetCell(out ExCell cell);
67 |
68 | int column = 1;
69 | if (DA.GetData(1, ref column)) cell.Column = column;
70 |
71 | int row = 1;
72 | if (DA.GetData(2, ref row)) cell.Row = row;
73 |
74 | bool isColumn = false;
75 | if (DA.GetData(3, ref isColumn)) cell.IsColumnAbsolute = isColumn;
76 |
77 | bool isRow = false;
78 | if (DA.GetData(4, ref isRow)) cell.IsRowAbsolute = isRow;
79 |
80 | DA.SetData(0, cell);
81 | DA.SetData(1, cell.Column);
82 | DA.SetData(2, cell.Row);
83 | DA.SetData(3, cell.IsColumnAbsolute);
84 | DA.SetData(4, cell.IsRowAbsolute);
85 | }
86 |
87 | ///
88 | /// Provides an Icon for the component.
89 | ///
90 | protected override System.Drawing.Bitmap Icon
91 | {
92 | get
93 | {
94 | //You can add image files to your project resources and access them like this:
95 | // return Resources.IconForThisComponent;
96 | return Properties.Resources.XL_Cel_Location;
97 | }
98 | }
99 |
100 | ///
101 | /// Gets the unique ID for this component. Do not change this ID after release.
102 | ///
103 | public override Guid ComponentGuid
104 | {
105 | get { return new Guid("5b4657ff-78fb-4222-9535-8db699c5a20c"); }
106 | }
107 | }
108 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Cell/GH_XL_Cel__Base.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Rhino.Geometry;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace ExcelPlus.Components
7 | {
8 | public abstract class GH_XL_Cel__Base : GH_Component
9 | {
10 | ///
11 | /// Initializes a new instance of the GH_XL_Cel__Base class.
12 | ///
13 | public GH_XL_Cel__Base()
14 | : base("GH_XL_Cel__Base", "Nickname",
15 | "Description",
16 | "Category", "Subcategory")
17 | {
18 | }
19 |
20 | public GH_XL_Cel__Base(string Name, string NickName, string Description, string Category, string Subcategory) : base(Name, NickName, Description, Category, Subcategory)
21 | {
22 | }
23 |
24 | ///
25 | /// Registers all the input parameters for this component.
26 | ///
27 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
28 | {
29 | pManager.AddGenericParameter(Constants.Cell.Name, Constants.Cell.NickName, Constants.Cell.Input, GH_ParamAccess.item);
30 | }
31 |
32 | ///
33 | /// Registers all the output parameters for this component.
34 | ///
35 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
36 | {
37 | pManager.AddGenericParameter(Constants.Cell.Name, Constants.Cell.NickName, Constants.Cell.Input, GH_ParamAccess.item);
38 | }
39 |
40 | ///
41 | /// This is the method that actually does the work.
42 | ///
43 | /// The DA object is used to retrieve from inputs and store in outputs.
44 | protected override void SolveInstance(IGH_DataAccess DA)
45 | {
46 | }
47 |
48 | ///
49 | /// Provides an Icon for the component.
50 | ///
51 | protected override System.Drawing.Bitmap Icon
52 | {
53 | get
54 | {
55 | //You can add image files to your project resources and access them like this:
56 | // return Resources.IconForThisComponent;
57 | return null;
58 | }
59 | }
60 |
61 | ///
62 | /// Gets the unique ID for this component. Do not change this ID after release.
63 | ///
64 | public override Guid ComponentGuid
65 | {
66 | get { return new Guid("918d2799-f2b7-4246-8bc7-aa02ee1d40c3"); }
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Format/GH_XL_Frm_Clear.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Parameters;
3 | using Grasshopper.Kernel.Types;
4 | using Rhino.Geometry;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Drawing;
8 |
9 | namespace ExcelPlus.Components
10 | {
11 | public class GH_XL_Frm_Clear : GH_XL_Frm__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_XL_Frm_Clear class.
15 | ///
16 | public GH_XL_Frm_Clear()
17 | : base("Clear", "Clear",
18 | "Clear the content or formatting for a Cell or all Cells in a Range or Worksheet",
19 | Constants.ShortName, Constants.SubFormat)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.primary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager.AddBooleanParameter("Clear Values", "V", "Clear all values", GH_ParamAccess.item, false);
38 | pManager[1].Optional = true;
39 | pManager.AddBooleanParameter("Clear Formatting", "F", "Clear all graphic formatting", GH_ParamAccess.item, false);
40 | pManager[2].Optional = true;
41 | pManager.AddBooleanParameter("Clear Conditions", "C", "Clear all conditional formatting", GH_ParamAccess.item, false);
42 | pManager[3].Optional = true;
43 | }
44 |
45 | ///
46 | /// Registers all the output parameters for this component.
47 | ///
48 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
49 | {
50 | base.RegisterOutputParams(pManager);
51 | }
52 |
53 | ///
54 | /// This is the method that actually does the work.
55 | ///
56 | /// The DA object is used to retrieve from inputs and store in outputs.
57 | protected override void SolveInstance(IGH_DataAccess DA)
58 | {
59 | IGH_Goo goo = null;
60 | if (!DA.GetData(0, ref goo)) return;
61 |
62 | bool clearValue = false;
63 | DA.GetData(1, ref clearValue);
64 |
65 | bool clearFormat = false;
66 | DA.GetData(2, ref clearFormat);
67 |
68 | if (goo.CastTo(out ExCell cell))
69 | {
70 | cell = new ExCell(cell);
71 | if (clearValue) cell.ClearValue();
72 | if (clearFormat) cell.ClearFormatting();
73 |
74 | DA.SetData(0, cell);
75 | }
76 | else if (goo.CastTo(out ExRange range))
77 | {
78 | range = new ExRange(range);
79 | if (clearValue) range.ClearValues();
80 | if (clearFormat) range.ClearFormatting();
81 |
82 | DA.SetData(0, range);
83 | }
84 | else if (goo.CastTo(out ExWorksheet sheet))
85 | {
86 | sheet = new ExWorksheet(sheet);
87 | if (clearValue) sheet.ClearValues();
88 | if (clearFormat) sheet.ClearFormatting();
89 |
90 | DA.SetData(0, sheet);
91 | }
92 | else if (goo.CastTo(out ExWorkbook book))
93 | {
94 | book = new ExWorkbook(book);
95 | if (clearValue) book.ClearValues();
96 | if (clearFormat) book.ClearFormatting();
97 |
98 | DA.SetData(0, book);
99 | }
100 | }
101 |
102 | ///
103 | /// Provides an Icon for the component.
104 | ///
105 | protected override System.Drawing.Bitmap Icon
106 | {
107 | get
108 | {
109 | //You can add image files to your project resources and access them like this:
110 | // return Resources.IconForThisComponent;
111 | return Properties.Resources.XL_Cel_Clear;
112 | }
113 | }
114 |
115 | ///
116 | /// Gets the unique ID for this component. Do not change this ID after release.
117 | ///
118 | public override Guid ComponentGuid
119 | {
120 | get { return new Guid("41370c2c-ebab-413e-bb81-dc3f14a033a9"); }
121 | }
122 | }
123 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Format/GH_XL_Frm_Size.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Parameters;
3 | using Grasshopper.Kernel.Types;
4 | using Rhino.Geometry;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Drawing;
8 |
9 | namespace ExcelPlus.Components
10 | {
11 | public class GH_XL_Frm_Size : GH_XL_Frm__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_XL_Frm_Size class.
15 | ///
16 | public GH_XL_Frm_Size()
17 | : base("Size", "Size",
18 | "Get or Set the Column and Row size for a Cell, Range, or Worksheet",
19 | Constants.ShortName, Constants.SubFormat)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.primary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager.AddNumberParameter("Width", "W", "The Cell column width", GH_ParamAccess.item);
38 | pManager[1].Optional = true;
39 | pManager.AddNumberParameter("Height", "H", "The Cell row height", GH_ParamAccess.item);
40 | pManager[2].Optional = true;
41 | }
42 |
43 | ///
44 | /// Registers all the output parameters for this component.
45 | ///
46 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
47 | {
48 | base.RegisterOutputParams(pManager);
49 | pManager.AddNumberParameter("Width", "W", "The Cell's column width", GH_ParamAccess.item);
50 | pManager.AddNumberParameter("Height", "H", "The Cell's row height", GH_ParamAccess.item);
51 | }
52 |
53 | ///
54 | /// This is the method that actually does the work.
55 | ///
56 | /// The DA object is used to retrieve from inputs and store in outputs.
57 | protected override void SolveInstance(IGH_DataAccess DA)
58 | {
59 | IGH_Goo goo = null;
60 | if (!DA.GetData(0, ref goo)) return;
61 |
62 | double width = -1;
63 | bool hasWidth = DA.GetData(1, ref width);
64 |
65 | double height = -1;
66 | bool hasHeight = DA.GetData(2, ref height);
67 |
68 | if (goo.CastTo(out ExCell cell))
69 | {
70 | cell = new ExCell(cell);
71 | if (hasWidth) cell.Width = width;
72 | if (hasHeight) cell.Height = height;
73 | DA.SetData(0, cell);
74 | DA.SetData(1, cell.Width);
75 | DA.SetData(2, cell.Height);
76 | }
77 | else if (goo.CastTo(out ExRange range))
78 | {
79 | range = new ExRange(range);
80 | if (hasWidth) range.ColumnWidth = width;
81 | if (hasHeight) range.RowHeight= height;
82 | DA.SetData(0, range);
83 | DA.SetData(1, range.ColumnWidth);
84 | DA.SetData(2, range.RowHeight);
85 | }
86 | else if (goo.CastTo(out ExWorksheet sheet))
87 | {
88 | sheet = new ExWorksheet(sheet);
89 | if (hasWidth) sheet.ColumnWidth = width;
90 | if (hasHeight) sheet.RowHeight = height;
91 | DA.SetData(0, sheet);
92 | DA.SetData(1, sheet.ColumnWidth);
93 | DA.SetData(2, sheet.RowHeight);
94 | }
95 | }
96 |
97 | ///
98 | /// Provides an Icon for the component.
99 | ///
100 | protected override System.Drawing.Bitmap Icon
101 | {
102 | get
103 | {
104 | //You can add image files to your project resources and access them like this:
105 | // return Resources.IconForThisComponent;
106 | return Properties.Resources.XL_Grp_Size;
107 | }
108 | }
109 |
110 | ///
111 | /// Gets the unique ID for this component. Do not change this ID after release.
112 | ///
113 | public override Guid ComponentGuid
114 | {
115 | get { return new Guid("34337940-6d34-49ff-9382-137d20900b1f"); }
116 | }
117 | }
118 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Format/GH_XL_Frm__Base.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Rhino.Geometry;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace ExcelPlus.Components
7 | {
8 | public abstract class GH_XL_Frm__Base : GH_Component
9 | {
10 | ///
11 | /// Initializes a new instance of the GH_XL_Frm__Base class.
12 | ///
13 | public GH_XL_Frm__Base()
14 | : base("GH_XL_Frm__Base", "Nickname",
15 | "Description",
16 | "Category", "Subcategory")
17 | {
18 | }
19 |
20 | public GH_XL_Frm__Base(string Name, string NickName, string Description, string Category, string Subcategory) : base(Name, NickName, Description, Category, Subcategory)
21 | {
22 | }
23 |
24 | ///
25 | /// Registers all the input parameters for this component.
26 | ///
27 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
28 | {
29 | pManager.AddGenericParameter("Object", "Obj", "A Cell, Range, Worksheet, or Workbook Object", GH_ParamAccess.item);
30 | }
31 |
32 | ///
33 | /// Registers all the output parameters for this component.
34 | ///
35 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
36 | {
37 | pManager.AddGenericParameter("Object", "Obj", "A Cell, Range, Worksheet, or Workbook Object", GH_ParamAccess.item);
38 | }
39 |
40 | ///
41 | /// This is the method that actually does the work.
42 | ///
43 | /// The DA object is used to retrieve from inputs and store in outputs.
44 | protected override void SolveInstance(IGH_DataAccess DA)
45 | {
46 | }
47 |
48 | ///
49 | /// Provides an Icon for the component.
50 | ///
51 | protected override System.Drawing.Bitmap Icon
52 | {
53 | get
54 | {
55 | //You can add image files to your project resources and access them like this:
56 | // return Resources.IconForThisComponent;
57 | return null;
58 | }
59 | }
60 |
61 | ///
62 | /// Gets the unique ID for this component. Do not change this ID after release.
63 | ///
64 | public override Guid ComponentGuid
65 | {
66 | get { return new Guid("63b9b529-604f-4ca1-8568-30d15cdd7387"); }
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Format/GH_XL_Gph_Fill.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Drawing;
7 |
8 | namespace ExcelPlus.Components
9 | {
10 | public class GH_XL_Gph_Fill : GH_XL_Gph__Base
11 | {
12 | ///
13 | /// Initializes a new instance of the GH_XL_Gph_Fill class.
14 | ///
15 | public GH_XL_Gph_Fill()
16 | : base("Fill", "Fill",
17 | "Get or Set the Fill formatting for a Cell, Range, or Worksheet",
18 | Constants.ShortName, Constants.SubFormat)
19 | {
20 | }
21 |
22 | ///
23 | /// Set Exposure level for the component.
24 | ///
25 | public override GH_Exposure Exposure
26 | {
27 | get { return GH_Exposure.primary; }
28 | }
29 |
30 | ///
31 | /// Registers all the input parameters for this component.
32 | ///
33 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
34 | {
35 | base.RegisterInputParams(pManager);
36 | pManager.AddColourParameter("Object Color", "C", "Object color", GH_ParamAccess.item);
37 | pManager[1].Optional = true;
38 | }
39 |
40 | ///
41 | /// Registers all the output parameters for this component.
42 | ///
43 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
44 | {
45 | base.RegisterOutputParams(pManager);
46 | pManager.AddColourParameter("Object Color", "C", "Object color", GH_ParamAccess.item);
47 | }
48 |
49 | ///
50 | /// This is the method that actually does the work.
51 | ///
52 | /// The DA object is used to retrieve from inputs and store in outputs.
53 | protected override void SolveInstance(IGH_DataAccess DA)
54 | {
55 | IGH_Goo goo = null;
56 | if (!DA.GetData(0, ref goo)) return;
57 |
58 | Color color = Color.Transparent;
59 |
60 | if(goo.CastTo(out ExCell cell))
61 | {
62 | cell = new ExCell(cell);
63 | if(DA.GetData(1,ref color)) cell.Graphic.FillColor = color;
64 |
65 | DA.SetData(0, cell);
66 | DA.SetData(1, cell.Graphic.FillColor);
67 | }
68 | else if(goo.CastTo(out ExRange range))
69 | {
70 | range = new ExRange(range);
71 | if (DA.GetData(1, ref color)) range.Graphic.FillColor = color;
72 |
73 | DA.SetData(0, range);
74 | DA.SetData(1, range.Graphic.FillColor);
75 | }
76 | else if (goo.CastTo(out ExWorksheet sheet))
77 | {
78 | sheet = new ExWorksheet(sheet);
79 | if (DA.GetData(1, ref color)) sheet.Graphic.FillColor = color;
80 |
81 | DA.SetData(0, sheet);
82 | DA.SetData(1, sheet.Graphic.FillColor);
83 | }
84 | else
85 | {
86 | return;
87 | }
88 |
89 | }
90 |
91 | ///
92 | /// Provides an Icon for the component.
93 | ///
94 | protected override System.Drawing.Bitmap Icon
95 | {
96 | get
97 | {
98 | //You can add image files to your project resources and access them like this:
99 | // return Resources.IconForThisComponent;
100 | return Properties.Resources.XL_Grp_Fill;
101 | }
102 | }
103 |
104 | ///
105 | /// Gets the unique ID for this component. Do not change this ID after release.
106 | ///
107 | public override Guid ComponentGuid
108 | {
109 | get { return new Guid("ff8be311-c3c2-46d3-bb99-bd5d7cd5410f"); }
110 | }
111 | }
112 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Format/GH_XL_Gph__Base.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Rhino.Geometry;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace ExcelPlus.Components
7 | {
8 | public abstract class GH_XL_Gph__Base : GH_XL_Frm__Base
9 | {
10 | ///
11 | /// Initializes a new instance of the GH_XL_Gph__Base class.
12 | ///
13 | public GH_XL_Gph__Base()
14 | : base("GH_XL_Gph__Base", "Nickname",
15 | "Description",
16 | "Category", "Subcategory")
17 | {
18 | }
19 |
20 | public GH_XL_Gph__Base(string Name, string NickName, string Description, string Category, string Subcategory) : base(Name, NickName, Description, Category, Subcategory)
21 | {
22 | }
23 |
24 | ///
25 | /// Registers all the input parameters for this component.
26 | ///
27 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
28 | {
29 | base.RegisterInputParams(pManager);
30 | pManager[0].Description = "A Cell or Range Object";
31 | }
32 |
33 | ///
34 | /// Registers all the output parameters for this component.
35 | ///
36 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
37 | {
38 | base.RegisterOutputParams(pManager);
39 | }
40 |
41 | ///
42 | /// This is the method that actually does the work.
43 | ///
44 | /// The DA object is used to retrieve from inputs and store in outputs.
45 | protected override void SolveInstance(IGH_DataAccess DA)
46 | {
47 | }
48 |
49 | ///
50 | /// Provides an Icon for the component.
51 | ///
52 | protected override System.Drawing.Bitmap Icon
53 | {
54 | get
55 | {
56 | //You can add image files to your project resources and access them like this:
57 | // return Resources.IconForThisComponent;
58 | return null;
59 | }
60 | }
61 |
62 | ///
63 | /// Gets the unique ID for this component. Do not change this ID after release.
64 | ///
65 | public override Guid ComponentGuid
66 | {
67 | get { return new Guid("73640250-a053-4a4d-9cce-5ee0d950eec4"); }
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Range/GH_XL_Rng_Construct.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Range
8 | {
9 | public class GH_XL_Rng_Construct : GH_XL_Rng__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Rng_Compile class.
13 | ///
14 | public GH_XL_Rng_Construct()
15 | : base("Construct Range", "Range",
16 | "Creates a Range from a series of Cells",
17 | Constants.ShortName, Constants.SubRange)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.primary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | pManager[0].Optional = true;
36 | pManager.AddGenericParameter("Cells", "Cel", Constants.Cell.Input, GH_ParamAccess.list);
37 | pManager[1].Optional = true;
38 | }
39 |
40 | ///
41 | /// Registers all the output parameters for this component.
42 | ///
43 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
44 | {
45 | base.RegisterOutputParams(pManager);
46 | }
47 |
48 | ///
49 | /// This is the method that actually does the work.
50 | ///
51 | /// The DA object is used to retrieve from inputs and store in outputs.
52 | protected override void SolveInstance(IGH_DataAccess DA)
53 | {
54 | IGH_Goo gooR = null;
55 | DA.GetData(0, ref gooR);
56 | gooR.TryGetRange(out ExRange range);
57 |
58 | List goos = new List();
59 | DA.GetDataList(1, goos);
60 | if (goos.TryCompileRange(out ExRange rng)) range.SetCells(rng.ActiveCells);
61 |
62 | DA.SetData(0, range);
63 | }
64 |
65 | ///
66 | /// Provides an Icon for the component.
67 | ///
68 | protected override System.Drawing.Bitmap Icon
69 | {
70 | get
71 | {
72 | //You can add image files to your project resources and access them like this:
73 | // return Resources.IconForThisComponent;
74 | return Properties.Resources.XL_Rng_Add;
75 | }
76 | }
77 |
78 | ///
79 | /// Gets the unique ID for this component. Do not change this ID after release.
80 | ///
81 | public override Guid ComponentGuid
82 | {
83 | get { return new Guid("8719fc09-3dca-4b8c-a3cd-34f6970f93c8"); }
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Range/GH_XL_Rng_Deconstruct.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Range
8 | {
9 | public class GH_XL_Rng_Deconstruct : GH_XL_Rng__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Rng_Cells class.
13 | ///
14 | public GH_XL_Rng_Deconstruct()
15 | : base("Deconstruct Range", "De Rng",
16 | "Deconstruct a Range into it's Cells",
17 | Constants.ShortName, Constants.SubRange)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.secondary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | pManager.AddBooleanParameter("Active", "A", "Return only active cells. If true Flip (F) input will be ignored", GH_ParamAccess.item, false);
36 | pManager[1].Optional = true;
37 | pManager.AddBooleanParameter("Flip", "F", "If true, cells are listed by column. If false, by row", GH_ParamAccess.item, true);
38 | pManager[2].Optional = true;
39 | }
40 |
41 | ///
42 | /// Registers all the output parameters for this component.
43 | ///
44 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
45 | {
46 | base.RegisterOutputParams(pManager);
47 | pManager.AddGenericParameter(Constants.Cell.Name, Constants.Cell.NickName, Constants.Cell.Outputs, GH_ParamAccess.list);
48 | pManager.AddTextParameter("Address", "A", "The Range address", GH_ParamAccess.item);
49 | }
50 |
51 | ///
52 | /// This is the method that actually does the work.
53 | ///
54 | /// The DA object is used to retrieve from inputs and store in outputs.
55 | protected override void SolveInstance(IGH_DataAccess DA)
56 | {
57 | IGH_Goo gooR = null;
58 | DA.GetData(0, ref gooR);
59 | gooR.TryGetRange(out ExRange range);
60 |
61 | bool active = false;
62 | DA.GetData(1, ref active);
63 |
64 | bool flip = false;
65 | DA.GetData(2, ref flip);
66 |
67 | DA.SetData(0, range);
68 |
69 | if (active)
70 | {
71 | DA.SetDataList(1, range.ActiveCells);
72 | }
73 | else
74 | {
75 | DA.SetDataList(1, range.Cells(flip));
76 | }
77 |
78 | DA.SetData(2, range.Address);
79 | }
80 |
81 | ///
82 | /// Provides an Icon for the component.
83 | ///
84 | protected override System.Drawing.Bitmap Icon
85 | {
86 | get
87 | {
88 | //You can add image files to your project resources and access them like this:
89 | // return Resources.IconForThisComponent;
90 | return Properties.Resources.XL_Rng_Deconstruct;
91 | }
92 | }
93 |
94 | ///
95 | /// Gets the unique ID for this component. Do not change this ID after release.
96 | ///
97 | public override Guid ComponentGuid
98 | {
99 | get { return new Guid("1e8b3c0e-dc75-4743-a50c-8fa0d6a6c8c0"); }
100 | }
101 | }
102 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Range/GH_XL_Rng_Explode.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Range
8 | {
9 | public class GH_XL_Rng_Explode :GH_Component
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Rng_SubRange class.
13 | ///
14 | public GH_XL_Rng_Explode()
15 | : base("Explode Range", "Explode Rng",
16 | "Explode all Cells in a Range into individual Ranges",
17 | Constants.ShortName, Constants.SubRange)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.tertiary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Input, GH_ParamAccess.item);
35 | pManager.AddBooleanParameter("Active", "A", "If true, only the active Cells in the Range will be returned", GH_ParamAccess.item, false);
36 | pManager[1].Optional = true;
37 | }
38 |
39 | ///
40 | /// Registers all the output parameters for this component.
41 | ///
42 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
43 | {
44 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Outputs, GH_ParamAccess.list);
45 | }
46 |
47 | ///
48 | /// This is the method that actually does the work.
49 | ///
50 | /// The DA object is used to retrieve from inputs and store in outputs.
51 | protected override void SolveInstance(IGH_DataAccess DA)
52 | {
53 | IGH_Goo gooR = null;
54 | DA.GetData(0, ref gooR);
55 | gooR.TryGetRange(out ExRange range);
56 |
57 | bool active = false;
58 | DA.GetData(1, ref active);
59 |
60 | DA.SetDataList(0, range.Explode(active));
61 | }
62 |
63 | ///
64 | /// Provides an Icon for the component.
65 | ///
66 | protected override System.Drawing.Bitmap Icon
67 | {
68 | get
69 | {
70 | //You can add image files to your project resources and access them like this:
71 | // return Resources.IconForThisComponent;
72 | return Properties.Resources.XL_Rng_Explode;
73 | }
74 | }
75 |
76 | ///
77 | /// Gets the unique ID for this component. Do not change this ID after release.
78 | ///
79 | public override Guid ComponentGuid
80 | {
81 | get { return new Guid("e9699125-bccf-4450-a604-ebf85f2d6b31"); }
82 | }
83 | }
84 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Range/GH_XL_Rng_Extents.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Range
8 | {
9 | public class GH_XL_Rng_Extents : GH_XL_Rng__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Rng_Extents class.
13 | ///
14 | public GH_XL_Rng_Extents()
15 | : base("Range Extents", "Rng Extents",
16 | "Returns the minimum Cell and maximum Cell of a Range",
17 | Constants.ShortName, Constants.SubRange)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.tertiary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Input, GH_ParamAccess.item);
35 | }
36 |
37 | ///
38 | /// Registers all the output parameters for this component.
39 | ///
40 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
41 | {
42 | pManager.AddGenericParameter("Minimum Cell", "<", Constants.Cell.Output, GH_ParamAccess.item);
43 | pManager.AddGenericParameter("Maximum Cell", ">", Constants.Cell.Output, GH_ParamAccess.item);
44 | }
45 |
46 | ///
47 | /// This is the method that actually does the work.
48 | ///
49 | /// The DA object is used to retrieve from inputs and store in outputs.
50 | protected override void SolveInstance(IGH_DataAccess DA)
51 | {
52 | IGH_Goo gooR = null;
53 | DA.GetData(0, ref gooR);
54 | gooR.TryGetRange(out ExRange range);
55 |
56 | DA.SetData(0, range.Min);
57 | DA.SetData(1, range.Max);
58 | }
59 |
60 | ///
61 | /// Provides an Icon for the component.
62 | ///
63 | protected override System.Drawing.Bitmap Icon
64 | {
65 | get
66 | {
67 | //You can add image files to your project resources and access them like this:
68 | // return Resources.IconForThisComponent;
69 | return Properties.Resources.XL_Rng_Extents;
70 | }
71 | }
72 |
73 | ///
74 | /// Gets the unique ID for this component. Do not change this ID after release.
75 | ///
76 | public override Guid ComponentGuid
77 | {
78 | get { return new Guid("3e1fb13c-d6b4-401d-9232-4618849a6db1"); }
79 | }
80 | }
81 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Range/GH_XL_Rng_GetCell.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Range
8 | {
9 | public class GH_XL_Rng_GetCell : GH_Component
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Rng_GetCell class.
13 | ///
14 | public GH_XL_Rng_GetCell()
15 | : base("Range Cell", "Rng Cell",
16 | "Returns specific cell",
17 | Constants.ShortName, Constants.SubRange)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.tertiary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Input, GH_ParamAccess.item);
35 | pManager.AddGenericParameter(Constants.Cell.Name, Constants.Cell.NickName, Constants.Cell.Input, GH_ParamAccess.item);
36 | }
37 |
38 | ///
39 | /// Registers all the output parameters for this component.
40 | ///
41 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
42 | {
43 | pManager.AddGenericParameter(Constants.Cell.Name, Constants.Cell.NickName, Constants.Cell.Input, GH_ParamAccess.item);
44 | pManager.AddBooleanParameter("Status", "S", "The status of the selected cell. Returns true if the cell had contents and false if it was blank", GH_ParamAccess.item);
45 | }
46 |
47 | ///
48 | /// This is the method that actually does the work.
49 | ///
50 | /// The DA object is used to retrieve from inputs and store in outputs.
51 | protected override void SolveInstance(IGH_DataAccess DA)
52 | {
53 | IGH_Goo gooA = null;
54 | DA.GetData(0, ref gooA);
55 | gooA.TryGetRange(out ExRange range);
56 |
57 | IGH_Goo gooB = null;
58 | DA.GetData(1, ref gooB);
59 | gooB.TryGetCell(out ExCell cell);
60 |
61 | bool status = range.TryGetCell(cell, out ExCell output);
62 |
63 | DA.SetData(0, output);
64 | DA.SetData(1, status);
65 | }
66 |
67 | ///
68 | /// Provides an Icon for the component.
69 | ///
70 | protected override System.Drawing.Bitmap Icon
71 | {
72 | get
73 | {
74 | //You can add image files to your project resources and access them like this:
75 | // return Resources.IconForThisComponent;
76 | return Properties.Resources.XL_Rng_GetCell;
77 | }
78 | }
79 |
80 | ///
81 | /// Gets the unique ID for this component. Do not change this ID after release.
82 | ///
83 | public override Guid ComponentGuid
84 | {
85 | get { return new Guid("d0d2d31c-98f1-4f79-b096-994f796b1a2d"); }
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Range/GH_XL_Rng_Merge.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Range
8 | {
9 | public class GH_XL_Rng_Merge : GH_XL_Rng__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Rng_Merge class.
13 | ///
14 | public GH_XL_Rng_Merge()
15 | : base("Merge Range", "Merge Rng",
16 | "Merge or unmerge a Range"+Environment.NewLine+ "(note: Ranges will be merged sequentially. If multiple Ranges overlap, the latter Range merge will be ignored.)",
17 | Constants.ShortName, Constants.SubRange)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.quarternary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | pManager.AddBooleanParameter("Merge", "M", "If true, the Cells in the Range will be merged and only the first Cell's value and formatting will be applied.", GH_ParamAccess.item);
36 | pManager[1].Optional = true;
37 | }
38 |
39 | ///
40 | /// Registers all the output parameters for this component.
41 | ///
42 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
43 | {
44 | base.RegisterOutputParams(pManager);
45 | pManager.AddBooleanParameter("Merged", "M", "The merge status of the Range", GH_ParamAccess.item);
46 | }
47 |
48 | ///
49 | /// This is the method that actually does the work.
50 | ///
51 | /// The DA object is used to retrieve from inputs and store in outputs.
52 | protected override void SolveInstance(IGH_DataAccess DA)
53 | {
54 | IGH_Goo gooR = null;
55 | DA.GetData(0, ref gooR);
56 | gooR.TryGetRange(out ExRange range);
57 |
58 | bool merged = false;
59 | if(DA.GetData(1, ref merged))range.IsMerged = merged;
60 |
61 | DA.SetData(0, range);
62 | DA.SetData(1, range.IsMerged);
63 | }
64 |
65 | ///
66 | /// Provides an Icon for the component.
67 | ///
68 | protected override System.Drawing.Bitmap Icon
69 | {
70 | get
71 | {
72 | //You can add image files to your project resources and access them like this:
73 | // return Resources.IconForThisComponent;
74 | return Properties.Resources.XL_Rng_Merge;
75 | }
76 | }
77 |
78 | ///
79 | /// Gets the unique ID for this component. Do not change this ID after release.
80 | ///
81 | public override Guid ComponentGuid
82 | {
83 | get { return new Guid("a8cfda30-23bd-479c-84e4-7e9dbeff2de9"); }
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Range/GH_XL_Rng_Populate.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Data;
3 | using Grasshopper.Kernel.Types;
4 | using Rhino.Geometry;
5 | using System;
6 | using System.Collections.Generic;
7 |
8 | namespace ExcelPlus.Components
9 | {
10 | public class GH_XL_Rng_Populate : GH_Component
11 | {
12 | ///
13 | /// Initializes a new instance of the GH_XL_Rng_Populate class.
14 | ///
15 | public GH_XL_Rng_Populate()
16 | : base("Populate Range", "Pop Rng",
17 | "Creates a Range from a starting Cell and data tree of values",
18 | Constants.ShortName, Constants.SubRange)
19 | {
20 | }
21 |
22 | ///
23 | /// Set Exposure level for the component.
24 | ///
25 | public override GH_Exposure Exposure
26 | {
27 | get { return GH_Exposure.primary; }
28 | }
29 |
30 | ///
31 | /// Registers all the input parameters for this component.
32 | ///
33 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
34 | {
35 | pManager.AddGenericParameter("Origin Cell", Constants.Cell.NickName, Constants.Cell.Input, GH_ParamAccess.item);
36 | pManager[0].Optional = true;
37 | pManager.AddTextParameter("Values", "V", "A datatree of values", GH_ParamAccess.tree);
38 | pManager.AddBooleanParameter("By Column", "C", "If true, branches will be written to Columns, if false to Rows", GH_ParamAccess.item, true);
39 | pManager[2].Optional = true;
40 | }
41 |
42 | ///
43 | /// Registers all the output parameters for this component.
44 | ///
45 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
46 | {
47 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Output, GH_ParamAccess.item);
48 | }
49 |
50 | ///
51 | /// This is the method that actually does the work.
52 | ///
53 | /// The DA object is used to retrieve from inputs and store in outputs.
54 | protected override void SolveInstance(IGH_DataAccess DA)
55 | {
56 | IGH_Goo goo = null;
57 | DA.GetData(0, ref goo);
58 | if (!goo.TryGetCell(out ExCell cell)) return;
59 |
60 | GH_Structure ghData = new GH_Structure();
61 |
62 | List> dataSet = new List>();
63 | if (!DA.GetDataTree(1, out ghData)) return;
64 |
65 | bool byColumn = true;
66 | DA.GetData(2, ref byColumn);
67 |
68 | foreach (List data in ghData.Branches)
69 | {
70 | dataSet.Add(data);
71 | }
72 |
73 | ExRange range = new ExRange(cell, dataSet, byColumn);
74 |
75 | DA.SetData(0, range);
76 | }
77 |
78 | ///
79 | /// Provides an Icon for the component.
80 | ///
81 | protected override System.Drawing.Bitmap Icon
82 | {
83 | get
84 | {
85 | //You can add image files to your project resources and access them like this:
86 | // return Resources.IconForThisComponent;
87 | return Properties.Resources.XL_Rng_Populate;
88 | }
89 | }
90 |
91 | ///
92 | /// Gets the unique ID for this component. Do not change this ID after release.
93 | ///
94 | public override Guid ComponentGuid
95 | {
96 | get { return new Guid("88560184-26a6-472c-884b-9d2b767f94e2"); }
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Range/GH_XL_Rng_SubRanges.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Range
8 | {
9 | public class GH_XL_Rng_SubRanges : GH_Component
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Rng_SubRanges class.
13 | ///
14 | public GH_XL_Rng_SubRanges()
15 | : base("Sub Ranges", "Sub Rng",
16 | "Returns a list of Ranges for each Column or Row",
17 | Constants.ShortName, Constants.SubRange)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.tertiary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Input, GH_ParamAccess.item);
35 | pManager.AddBooleanParameter("By Column", "C", "If true, Ranges will be returned by column. If false, by row", GH_ParamAccess.item, false);
36 | pManager[1].Optional = true;
37 | }
38 |
39 | ///
40 | /// Registers all the output parameters for this component.
41 | ///
42 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
43 | {
44 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Outputs, GH_ParamAccess.list);
45 | }
46 |
47 | ///
48 | /// This is the method that actually does the work.
49 | ///
50 | /// The DA object is used to retrieve from inputs and store in outputs.
51 | protected override void SolveInstance(IGH_DataAccess DA)
52 | {
53 | IGH_Goo gooR = null;
54 | DA.GetData(0, ref gooR);
55 | gooR.TryGetRange(out ExRange range);
56 |
57 | bool byColumn = false;
58 | DA.GetData(1, ref byColumn);
59 |
60 | DA.SetDataList(0, range.SubRanges(byColumn));
61 | }
62 |
63 | ///
64 | /// Provides an Icon for the component.
65 | ///
66 | protected override System.Drawing.Bitmap Icon
67 | {
68 | get
69 | {
70 | //You can add image files to your project resources and access them like this:
71 | // return Resources.IconForThisComponent;
72 | return Properties.Resources.XL_Rng_By;
73 | }
74 | }
75 |
76 | ///
77 | /// Gets the unique ID for this component. Do not change this ID after release.
78 | ///
79 | public override Guid ComponentGuid
80 | {
81 | get { return new Guid("3b0f3bfd-49bb-48a4-983a-4af403017335"); }
82 | }
83 | }
84 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Range/GH_XL_Rng__Base.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Rhino.Geometry;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace ExcelPlus.Components.Range
7 | {
8 | public abstract class GH_XL_Rng__Base : GH_Component
9 | {
10 | ///
11 | /// Initializes a new instance of the GH_XL_Rng__Base class.
12 | ///
13 | public GH_XL_Rng__Base()
14 | : base("GH_XL_Rng__Base", "Nickname",
15 | "Description",
16 | "Category", "Subcategory")
17 | {
18 | }
19 |
20 | public GH_XL_Rng__Base(string Name, string NickName, string Description, string Category, string Subcategory) : base(Name, NickName, Description, Category, Subcategory)
21 | {
22 | }
23 |
24 | ///
25 | /// Registers all the input parameters for this component.
26 | ///
27 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
28 | {
29 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Input, GH_ParamAccess.item);
30 | }
31 |
32 | ///
33 | /// Registers all the output parameters for this component.
34 | ///
35 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
36 | {
37 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Output, GH_ParamAccess.item);
38 | }
39 |
40 | ///
41 | /// This is the method that actually does the work.
42 | ///
43 | /// The DA object is used to retrieve from inputs and store in outputs.
44 | protected override void SolveInstance(IGH_DataAccess DA)
45 | {
46 | }
47 |
48 | ///
49 | /// Provides an Icon for the component.
50 | ///
51 | protected override System.Drawing.Bitmap Icon
52 | {
53 | get
54 | {
55 | //You can add image files to your project resources and access them like this:
56 | // return Resources.IconForThisComponent;
57 | return null;
58 | }
59 | }
60 |
61 | ///
62 | /// Gets the unique ID for this component. Do not change this ID after release.
63 | ///
64 | public override Guid ComponentGuid
65 | {
66 | get { return new Guid("9ccfbfd4-55e4-42eb-b50f-3cc9a8891cfa"); }
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Range/RH_XL_Wbk_AddRange.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Range
8 | {
9 | public class RH_XL_Wbk_AddRange : GH_Component
10 | {
11 | ///
12 | /// Initializes a new instance of the RH_XL_Wbk_SetRange class.
13 | ///
14 | public RH_XL_Wbk_AddRange()
15 | : base("New Range", "Rng New",
16 | "Creates a new Range from a minimum and maximum Cell",
17 | Constants.ShortName, Constants.SubRange)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.primary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | pManager.AddGenericParameter("Minimum Cell", "<", Constants.Cell.Input, GH_ParamAccess.item);
35 | pManager[0].Optional = true;
36 | pManager.AddGenericParameter("Maximum Cell", ">", Constants.Cell.Input, GH_ParamAccess.item);
37 | pManager[1].Optional = true;
38 | }
39 |
40 | ///
41 | /// Registers all the output parameters for this component.
42 | ///
43 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
44 | {
45 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Output, GH_ParamAccess.item);
46 | }
47 |
48 | ///
49 | /// This is the method that actually does the work.
50 | ///
51 | /// The DA object is used to retrieve from inputs and store in outputs.
52 | protected override void SolveInstance(IGH_DataAccess DA)
53 | {
54 | IGH_Goo gooA = null;
55 | DA.GetData(0, ref gooA);
56 | gooA.TryGetCell(out ExCell min);
57 |
58 | IGH_Goo gooB = null;
59 | DA.GetData(1, ref gooB);
60 | gooB.TryGetCell(out ExCell max);
61 |
62 | DA.SetData(0, new ExRange(min,max));
63 | }
64 |
65 | ///
66 | /// Provides an Icon for the component.
67 | ///
68 | protected override System.Drawing.Bitmap Icon
69 | {
70 | get
71 | {
72 | //You can add image files to your project resources and access them like this:
73 | // return Resources.IconForThisComponent;
74 | return Properties.Resources.XL_Rng_GetCells;
75 | }
76 | }
77 |
78 | ///
79 | /// Gets the unique ID for this component. Do not change this ID after release.
80 | ///
81 | public override Guid ComponentGuid
82 | {
83 | get { return new Guid("debea2e6-7917-490c-ada8-dfe4d1843747"); }
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Workbook/GH_XL_Wbk_Construct.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components
8 | {
9 | public class GH_XL_Wbk_Construct : GH_XL_Wbk__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Wbk_Construct class.
13 | ///
14 | public GH_XL_Wbk_Construct()
15 | : base("Construct Workbook", "Workbook",
16 | "Construct a Workbook",
17 | Constants.ShortName, Constants.SubWorkBooks)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.primary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | pManager[0].Optional = true;
36 | pManager.AddGenericParameter(Constants.Worksheet.Name, Constants.Worksheet.NickName, Constants.Worksheet.Input, GH_ParamAccess.list);
37 | pManager[1].Optional = true;
38 | }
39 |
40 | ///
41 | /// Registers all the output parameters for this component.
42 | ///
43 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
44 | {
45 | base.RegisterOutputParams(pManager);
46 | }
47 |
48 | ///
49 | /// This is the method that actually does the work.
50 | ///
51 | /// The DA object is used to retrieve from inputs and store in outputs.
52 | protected override void SolveInstance(IGH_DataAccess DA)
53 | {
54 | IGH_Goo gooB = null;
55 | DA.GetData(0, ref gooB);
56 | if (!gooB.TryGetWorkbook(out ExWorkbook workbook)) return;
57 |
58 | List goos = new List();
59 | DA.GetDataList(1, goos);
60 | if (goos.TryCompileWorkbook(out ExWorkbook book)) workbook.Sheets.AddRange(book.GetSheets()); ;
61 |
62 | DA.SetData(0, workbook);
63 | }
64 |
65 | ///
66 | /// Provides an Icon for the component.
67 | ///
68 | protected override System.Drawing.Bitmap Icon
69 | {
70 | get
71 | {
72 | //You can add image files to your project resources and access them like this:
73 | // return Resources.IconForThisComponent;
74 | return Properties.Resources.XL_Wbk_Add;
75 | }
76 | }
77 |
78 | ///
79 | /// Gets the unique ID for this component. Do not change this ID after release.
80 | ///
81 | public override Guid ComponentGuid
82 | {
83 | get { return new Guid("73a8c72f-98c6-438c-880a-b915e1452671"); }
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Workbook/GH_XL_Wbk_Deconstruct.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components.Workbook
8 | {
9 | public class GH_XL_Wbk_Deconstruct : GH_XL_Wbk__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Wbk_Deconstruct class.
13 | ///
14 | public GH_XL_Wbk_Deconstruct()
15 | : base("Deconstruct Workbook", "De Wbk",
16 | "Deconstruct a Workbook into its Worksheets",
17 | Constants.ShortName, Constants.SubWorkBooks)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.secondary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | pManager.AddTextParameter("Names", "N", "Optional list of Worksheet names", GH_ParamAccess.list);
36 | pManager[1].Optional = true;
37 | }
38 |
39 | ///
40 | /// Registers all the output parameters for this component.
41 | ///
42 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
43 | {
44 | base.RegisterOutputParams(pManager);
45 | pManager.AddGenericParameter(Constants.Worksheet.Name, Constants.Worksheet.NickName, Constants.Worksheet.Outputs, GH_ParamAccess.list);
46 | }
47 |
48 | ///
49 | /// This is the method that actually does the work.
50 | ///
51 | /// The DA object is used to retrieve from inputs and store in outputs.
52 | protected override void SolveInstance(IGH_DataAccess DA)
53 | {
54 | IGH_Goo gooB = null;
55 | DA.GetData(0, ref gooB);
56 | if (!gooB.TryGetWorkbook(out ExWorkbook workbook)) return;
57 |
58 | List names = new List();
59 | if(DA.GetDataList(1,names))
60 | {
61 | List sheets = new List();
62 | foreach (string name in names) if (workbook.TryGetSheet(name, out ExWorksheet sheet)) sheets.Add(sheet);
63 | DA.SetDataList(1, sheets);
64 | }
65 | else
66 | {
67 | DA.SetDataList(1, workbook.GetWorksheets());
68 | }
69 |
70 |
71 | DA.SetData(0, workbook);
72 |
73 | }
74 |
75 | ///
76 | /// Provides an Icon for the component.
77 | ///
78 | protected override System.Drawing.Bitmap Icon
79 | {
80 | get
81 | {
82 | //You can add image files to your project resources and access them like this:
83 | // return Resources.IconForThisComponent;
84 | return Properties.Resources.XL_Wbk_Deconstruct;
85 | }
86 | }
87 |
88 | ///
89 | /// Gets the unique ID for this component. Do not change this ID after release.
90 | ///
91 | public override Guid ComponentGuid
92 | {
93 | get { return new Guid("d43c1928-c84a-44c6-b694-fd562c6cad4e"); }
94 | }
95 | }
96 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Workbook/GH_XL_Wbk_Open.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Rhino.Geometry;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace ExcelPlus.Components.Workbook
7 | {
8 | public class GH_XL_Wbk_Open : GH_Component
9 | {
10 | ///
11 | /// Initializes a new instance of the GH_XL_Wbk_Open class.
12 | ///
13 | public GH_XL_Wbk_Open()
14 | : base("Open Workbook", "Open Wbk",
15 | "Open a Workbook from an Excel file"+Environment.NewLine+ "Supported extensions are '.xlsx', '.xlsm', '.xltx' and '.xltm'.'",
16 | Constants.ShortName, Constants.SubWorkBooks)
17 | {
18 | }
19 |
20 | ///
21 | /// Set Exposure level for the component.
22 | ///
23 | public override GH_Exposure Exposure
24 | {
25 | get { return GH_Exposure.senary; }
26 | }
27 |
28 | ///
29 | /// Registers all the input parameters for this component.
30 | ///
31 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
32 | {
33 | pManager.AddTextParameter("Filepath", "P", "The full file path to an Excel file" + Environment.NewLine + "Supported extensions are '.xlsx', '.xlsm', '.xltx', and '.xltm'", GH_ParamAccess.item);
34 | pManager.AddBooleanParameter(Constants.Activate.Name, Constants.Activate.NickName, Constants.Activate.Input, GH_ParamAccess.item);
35 | }
36 |
37 | ///
38 | /// Registers all the output parameters for this component.
39 | ///
40 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
41 | {
42 | pManager.AddGenericParameter(Constants.Workbook.Name, Constants.Workbook.NickName, Constants.Workbook.Output, GH_ParamAccess.item);
43 | }
44 |
45 | ///
46 | /// This is the method that actually does the work.
47 | ///
48 | /// The DA object is used to retrieve from inputs and store in outputs.
49 | protected override void SolveInstance(IGH_DataAccess DA)
50 | {
51 |
52 | bool activate = false;
53 | DA.GetData(1, ref activate);
54 | if (activate)
55 | {
56 | string filepath = string.Empty;
57 | if (DA.GetData(0, ref filepath))
58 | {
59 | ExWorkbook workbook = new ExWorkbook();
60 | workbook.Open(filepath);
61 | DA.SetData(0, workbook);
62 | }
63 | }
64 |
65 | }
66 |
67 | ///
68 | /// Provides an Icon for the component.
69 | ///
70 | protected override System.Drawing.Bitmap Icon
71 | {
72 | get
73 | {
74 | //You can add image files to your project resources and access them like this:
75 | // return Resources.IconForThisComponent;
76 | return Properties.Resources.XL_Wbk_Open;
77 | }
78 | }
79 |
80 | ///
81 | /// Gets the unique ID for this component. Do not change this ID after release.
82 | ///
83 | public override Guid ComponentGuid
84 | {
85 | get { return new Guid("0f4a8727-5d30-4a07-a4cc-279197f1a7b7"); }
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Workbook/GH_XL_Wbk_Properties.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components
8 | {
9 | public class GH_XL_Wbk_Properties : GH_XL_Wbk__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Wbk_Properties class.
13 | ///
14 | public GH_XL_Wbk_Properties()
15 | : base("Workbook Properties", "Wbk Prop",
16 | "Get or set Workbook properties",
17 | Constants.ShortName, Constants.SubWorkBooks)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.secondary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | pManager.AddTextParameter("Name", "N", "The Workbook Name", GH_ParamAccess.item);
36 | pManager[1].Optional = true;
37 | }
38 |
39 | ///
40 | /// Registers all the output parameters for this component.
41 | ///
42 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
43 | {
44 | base.RegisterOutputParams(pManager);
45 | pManager.AddTextParameter("Name", "N", "The Workbook Name", GH_ParamAccess.item);
46 | }
47 |
48 | ///
49 | /// This is the method that actually does the work.
50 | ///
51 | /// The DA object is used to retrieve from inputs and store in outputs.
52 | protected override void SolveInstance(IGH_DataAccess DA)
53 | {
54 | IGH_Goo gooB = null;
55 | DA.GetData(0, ref gooB);
56 | if (!gooB.TryGetWorkbook(out ExWorkbook workbook)) return;
57 |
58 | string name = string.Empty;
59 | if (DA.GetData(1, ref name)) workbook.Name = name;
60 |
61 | DA.SetData(0, workbook);
62 | DA.SetData(1, workbook.Name);
63 | }
64 |
65 | ///
66 | /// Provides an Icon for the component.
67 | ///
68 | protected override System.Drawing.Bitmap Icon
69 | {
70 | get
71 | {
72 | //You can add image files to your project resources and access them like this:
73 | // return Resources.IconForThisComponent;
74 | return Properties.Resources.XL_Wbk_Edit;
75 | }
76 | }
77 |
78 | ///
79 | /// Gets the unique ID for this component. Do not change this ID after release.
80 | ///
81 | public override Guid ComponentGuid
82 | {
83 | get { return new Guid("30b99ea0-9fa7-49bc-8594-1f85d6d58051"); }
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Workbook/GH_XL_Wbk_Read.cs.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Rhino.Geometry;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace ExcelPlus.Components.Workbook
7 | {
8 | public class GH_XL_Wbk_Read : GH_Component
9 | {
10 | ///
11 | /// Initializes a new instance of the GH_XL_Wbk_Read class.
12 | ///
13 | public GH_XL_Wbk_Read()
14 | : base("Read Workbook", "Read Wbk",
15 | "Read a Workbook from a Memory Stream string",
16 | Constants.ShortName, Constants.SubWorkBooks)
17 | {
18 | }
19 |
20 | ///
21 | /// Set Exposure level for the component.
22 | ///
23 | public override GH_Exposure Exposure
24 | {
25 | get { return GH_Exposure.septenary; }
26 | }
27 |
28 | ///
29 | /// Registers all the input parameters for this component.
30 | ///
31 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
32 | {
33 | pManager.AddTextParameter("Stream", "S", "A string version of an Excel file memory stream", GH_ParamAccess.item);
34 | pManager.AddBooleanParameter(Constants.Activate.Name, Constants.Activate.NickName, Constants.Activate.Input, GH_ParamAccess.item);
35 | }
36 |
37 | ///
38 | /// Registers all the output parameters for this component.
39 | ///
40 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
41 | {
42 | pManager.AddGenericParameter(Constants.Workbook.Name, Constants.Workbook.NickName, Constants.Workbook.Output, GH_ParamAccess.item);
43 | }
44 |
45 | ///
46 | /// This is the method that actually does the work.
47 | ///
48 | /// The DA object is used to retrieve from inputs and store in outputs.
49 | protected override void SolveInstance(IGH_DataAccess DA)
50 | {
51 |
52 | bool activate = false;
53 | DA.GetData(1, ref activate);
54 | if (activate)
55 | {
56 | string stream = string.Empty;
57 | if (DA.GetData(0, ref stream))
58 | {
59 | ExWorkbook workbook = new ExWorkbook();
60 | workbook.Read(stream);
61 | DA.SetData(0, workbook);
62 | }
63 | }
64 |
65 | }
66 |
67 | ///
68 | /// Provides an Icon for the component.
69 | ///
70 | protected override System.Drawing.Bitmap Icon
71 | {
72 | get
73 | {
74 | //You can add image files to your project resources and access them like this:
75 | // return Resources.IconForThisComponent;
76 | return Properties.Resources.XL_Wbk_Read;
77 | }
78 | }
79 |
80 | ///
81 | /// Gets the unique ID for this component. Do not change this ID after release.
82 | ///
83 | public override Guid ComponentGuid
84 | {
85 | get { return new Guid("d7c666ef-d0a3-4921-af48-33eec41d2a9f"); }
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Workbook/GH_XL_Wbk_Run.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components
8 | {
9 | public class GH_XL_Wbk_Run : GH_XL_Wbk__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Wbk_Run class.
13 | ///
14 | public GH_XL_Wbk_Run()
15 | : base("Run Workbook", "Run",
16 | "Computes all formulas in a Workbook",
17 | Constants.ShortName, Constants.SubWorkBooks)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.primary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | pManager[0].Optional = true;
36 | }
37 |
38 | ///
39 | /// Registers all the output parameters for this component.
40 | ///
41 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
42 | {
43 | base.RegisterOutputParams(pManager);
44 | }
45 |
46 | ///
47 | /// This is the method that actually does the work.
48 | ///
49 | /// The DA object is used to retrieve from inputs and store in outputs.
50 | protected override void SolveInstance(IGH_DataAccess DA)
51 | {
52 | IGH_Goo gooB = null;
53 | DA.GetData(0, ref gooB);
54 | if (!gooB.TryGetWorkbook(out ExWorkbook workbook)) return;
55 |
56 | workbook.Refresh();
57 | DA.SetData(0, workbook);
58 | }
59 |
60 | ///
61 | /// Provides an Icon for the component.
62 | ///
63 | protected override System.Drawing.Bitmap Icon
64 | {
65 | get
66 | {
67 | //You can add image files to your project resources and access them like this:
68 | // return Resources.IconForThisComponent;
69 | return Properties.Resources.XL_Wbk_Refresh;
70 | }
71 | }
72 |
73 | ///
74 | /// Gets the unique ID for this component. Do not change this ID after release.
75 | ///
76 | public override Guid ComponentGuid
77 | {
78 | get { return new Guid("a11ece8b-1aea-4987-9fd0-354213f83bc2"); }
79 | }
80 | }
81 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Workbook/GH_XL_Wbk_Save.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Parameters;
3 | using Grasshopper.Kernel.Types;
4 | using Rhino.Geometry;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 |
9 | namespace ExcelPlus.Components
10 | {
11 | public class GH_XL_Wbk_Save : GH_XL_Wbk__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_Ex_Wb_Save class.
15 | ///
16 | public GH_XL_Wbk_Save()
17 | : base("Save Workbook", "Save Wbk",
18 | "Save a Workbook to an Excel file",
19 | Constants.ShortName, Constants.SubWorkBooks)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.senary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager.AddTextParameter("Folder Path", "F", "The path to the Workbook", GH_ParamAccess.item);
38 | pManager[1].Optional = true;
39 | pManager.AddTextParameter("File Name", "N", "The Workbook name", GH_ParamAccess.item);
40 | pManager[2].Optional = true;
41 | pManager.AddIntegerParameter("Extensions", "E", "The file type extension", GH_ParamAccess.item, 0);
42 | pManager[3].Optional = true;
43 | pManager.AddBooleanParameter(Constants.Activate.Name, Constants.Activate.NickName, Constants.Activate.Input, GH_ParamAccess.item);
44 |
45 | Param_Integer paramA = (Param_Integer)pManager[3];
46 | foreach (Extensions value in Enum.GetValues(typeof(Extensions)))
47 | {
48 | paramA.AddNamedValue(value.ToString(), (int)value);
49 | }
50 | }
51 |
52 | ///
53 | /// Registers all the output parameters for this component.
54 | ///
55 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
56 | {
57 | base.RegisterOutputParams(pManager);
58 | pManager.AddTextParameter("FilePath", "P", "The full filepath to the saved file", GH_ParamAccess.item);
59 | }
60 |
61 | ///
62 | /// This is the method that actually does the work.
63 | ///
64 | /// The DA object is used to retrieve from inputs and store in outputs.
65 | protected override void SolveInstance(IGH_DataAccess DA)
66 | {
67 |
68 | bool activate = false;
69 | DA.GetData(4, ref activate);
70 | if (activate)
71 | {
72 | IGH_Goo gooB = null;
73 | DA.GetData(0, ref gooB);
74 | if (!gooB.TryGetWorkbook(out ExWorkbook workbook)) return;
75 |
76 | string path = "C:\\Users\\Public\\Documents\\";
77 | bool hasPath = DA.GetData(1, ref path);
78 |
79 | if (!hasPath)
80 | {
81 | if (this.OnPingDocument().FilePath != null)
82 | {
83 | path = Path.GetDirectoryName(this.OnPingDocument().FilePath) + "\\";
84 | }
85 | }
86 |
87 | if (!Directory.Exists(path))
88 | {
89 | this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "The file provided path does not exist. Please verify this is a valid file path.");
90 | return;
91 | }
92 |
93 | string name = Constants.UniqueName;
94 | if (workbook.Name != string.Empty) name = workbook.Name;
95 | DA.GetData(2, ref name);
96 |
97 | int ext = 0;
98 | DA.GetData(3, ref ext);
99 |
100 | string filepath = workbook.Save(path,name, (Extensions)ext);
101 |
102 | DA.SetData(0, workbook);
103 | DA.SetData(1, filepath);
104 | }
105 |
106 |
107 | }
108 |
109 | ///
110 | /// Provides an Icon for the component.
111 | ///
112 | protected override System.Drawing.Bitmap Icon
113 | {
114 | get
115 | {
116 | //You can add image files to your project resources and access them like this:
117 | // return Resources.IconForThisComponent;
118 | return Properties.Resources.XL_Wbk_Save;
119 | }
120 | }
121 |
122 | ///
123 | /// Gets the unique ID for this component. Do not change this ID after release.
124 | ///
125 | public override Guid ComponentGuid
126 | {
127 | get { return new Guid("2083eddc-f00d-4773-8d49-81875571b5ed"); }
128 | }
129 | }
130 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Workbook/GH_XL_Wbk_Write.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Parameters;
3 | using Grasshopper.Kernel.Types;
4 | using Rhino.Geometry;
5 | using System;
6 | using System.Collections.Generic;
7 |
8 | namespace ExcelPlus.Components.Workbook
9 | {
10 | public class GH_XL_Wbk_Write : GH_XL_Wbk__Base
11 | {
12 | ///
13 | /// Initializes a new instance of the GH_XL_Wbk_Write class.
14 | ///
15 | public GH_XL_Wbk_Write()
16 | : base("Write Workbook", "Write Wbk",
17 | "Write a Workbook to a Memory Stream string",
18 | Constants.ShortName, Constants.SubWorkBooks)
19 | {
20 | }
21 |
22 | ///
23 | /// Set Exposure level for the component.
24 | ///
25 | public override GH_Exposure Exposure
26 | {
27 | get { return GH_Exposure.septenary; }
28 | }
29 |
30 | ///
31 | /// Registers all the input parameters for this component.
32 | ///
33 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
34 | {
35 | base.RegisterInputParams(pManager);
36 | pManager.AddBooleanParameter(Constants.Activate.Name, Constants.Activate.NickName, Constants.Activate.Input, GH_ParamAccess.item);
37 |
38 | }
39 |
40 | ///
41 | /// Registers all the output parameters for this component.
42 | ///
43 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
44 | {
45 | base.RegisterOutputParams(pManager);
46 | pManager.AddTextParameter("Stream", "S", "The memory stream", GH_ParamAccess.item);
47 | }
48 |
49 | ///
50 | /// This is the method that actually does the work.
51 | ///
52 | /// The DA object is used to retrieve from inputs and store in outputs.
53 | protected override void SolveInstance(IGH_DataAccess DA)
54 | {
55 |
56 | bool activate = false;
57 | DA.GetData(1, ref activate);
58 | if (activate)
59 | {
60 | IGH_Goo gooB = null;
61 | DA.GetData(0, ref gooB);
62 | if (!gooB.TryGetWorkbook(out ExWorkbook workbook)) return;
63 |
64 | string stream = workbook.Write();
65 |
66 | DA.SetData(0, workbook);
67 | DA.SetData(1, stream);
68 | }
69 |
70 |
71 | }
72 |
73 | ///
74 | /// Provides an Icon for the component.
75 | ///
76 | protected override System.Drawing.Bitmap Icon
77 | {
78 | get
79 | {
80 | //You can add image files to your project resources and access them like this:
81 | // return Resources.IconForThisComponent;
82 | return Properties.Resources.XL_Wbk_Wrt;
83 | }
84 | }
85 |
86 | ///
87 | /// Gets the unique ID for this component. Do not change this ID after release.
88 | ///
89 | public override Guid ComponentGuid
90 | {
91 | get { return new Guid("db01e4c2-daca-41a6-8b55-1024d386dbde"); }
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Workbook/GH_XL_Wbk__Base.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Rhino.Geometry;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace ExcelPlus.Components
7 | {
8 | public abstract class GH_XL_Wbk__Base : GH_Component
9 | {
10 | ///
11 | /// Initializes a new instance of the GH_XL_Wbk__Base class.
12 | ///
13 | public GH_XL_Wbk__Base()
14 | : base("GH_XL_Wbk__Base", "Nickname",
15 | "Description",
16 | "Category", "Subcategory")
17 | {
18 | }
19 |
20 | public GH_XL_Wbk__Base(string Name, string NickName, string Description, string Category, string Subcategory) : base(Name, NickName, Description, Category, Subcategory)
21 | {
22 | }
23 |
24 | ///
25 | /// Registers all the input parameters for this component.
26 | ///
27 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
28 | {
29 | pManager.AddGenericParameter(Constants.Workbook.Name, Constants.Workbook.NickName, Constants.Workbook.Input, GH_ParamAccess.item);
30 | }
31 |
32 | ///
33 | /// Registers all the output parameters for this component.
34 | ///
35 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
36 | {
37 | pManager.AddGenericParameter(Constants.Workbook.Name, Constants.Workbook.NickName, Constants.Workbook.Output, GH_ParamAccess.item);
38 | }
39 |
40 | ///
41 | /// This is the method that actually does the work.
42 | ///
43 | /// The DA object is used to retrieve from inputs and store in outputs.
44 | protected override void SolveInstance(IGH_DataAccess DA)
45 | {
46 | }
47 |
48 | ///
49 | /// Provides an Icon for the component.
50 | ///
51 | protected override System.Drawing.Bitmap Icon
52 | {
53 | get
54 | {
55 | //You can add image files to your project resources and access them like this:
56 | // return Resources.IconForThisComponent;
57 | return null;
58 | }
59 | }
60 |
61 | ///
62 | /// Gets the unique ID for this component. Do not change this ID after release.
63 | ///
64 | public override Guid ComponentGuid
65 | {
66 | get { return new Guid("19c1341d-a198-4587-a3e5-354bd5d357a6"); }
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Worksheet/GH_XL_Wks_Construct.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components
8 | {
9 | public class GH_XL_Wks_Construct : GH_XL_Wks__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Wks_Construct class.
13 | ///
14 | public GH_XL_Wks_Construct()
15 | : base("Construct Worksheet", "Worksheet",
16 | "Construct a Worksheet",
17 | Constants.ShortName, Constants.SubWorkSheets)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.primary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | pManager[0].Optional = true;
36 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Input, GH_ParamAccess.list);
37 | pManager[1].Optional = true;
38 | }
39 |
40 | ///
41 | /// Registers all the output parameters for this component.
42 | ///
43 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
44 | {
45 | base.RegisterOutputParams(pManager);
46 | }
47 |
48 | ///
49 | /// This is the method that actually does the work.
50 | ///
51 | /// The DA object is used to retrieve from inputs and store in outputs.
52 | protected override void SolveInstance(IGH_DataAccess DA)
53 | {
54 | IGH_Goo gooS = null;
55 | DA.GetData(0, ref gooS);
56 | if (!gooS.TryGetWorksheet(out ExWorksheet worksheet)) return;
57 |
58 | List goor = new List();
59 | DA.GetDataList(1, goor);
60 | if (goor.TryCompileWorksheet(out ExWorksheet sheet)) worksheet.Ranges.AddRange(sheet.GetRanges());
61 |
62 | DA.SetData(0, worksheet);
63 | }
64 |
65 | ///
66 | /// Provides an Icon for the component.
67 | ///
68 | protected override System.Drawing.Bitmap Icon
69 | {
70 | get
71 | {
72 | //You can add image files to your project resources and access them like this:
73 | // return Resources.IconForThisComponent;
74 | return Properties.Resources.XL_Wks_Add;
75 | }
76 | }
77 |
78 | ///
79 | /// Gets the unique ID for this component. Do not change this ID after release.
80 | ///
81 | public override Guid ComponentGuid
82 | {
83 | get { return new Guid("3b9ad57b-7f0f-43b1-b729-6345c7a2f723"); }
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Worksheet/GH_XL_Wks_Deconstruct.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components
8 | {
9 | public class GH_XL_Wks_Deconstruct : GH_XL_Wks__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Wks_GetCells class.
13 | ///
14 | public GH_XL_Wks_Deconstruct()
15 | : base("Deconstruct Worksheet", "De Wks",
16 | "Deconstruct a Worksheet into it's Ranges and active Cells",
17 | Constants.ShortName, Constants.SubWorkSheets)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.secondary; }
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
33 | {
34 | base.RegisterInputParams(pManager);
35 | }
36 |
37 | ///
38 | /// Registers all the output parameters for this component.
39 | ///
40 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
41 | {
42 | base.RegisterOutputParams(pManager);
43 | pManager.AddGenericParameter(Constants.Range.Name, Constants.Range.NickName, Constants.Range.Outputs, GH_ParamAccess.list);
44 | pManager.AddGenericParameter(Constants.Cell.Name, Constants.Cell.NickName, Constants.Cell.Outputs, GH_ParamAccess.list);
45 | }
46 |
47 | ///
48 | /// This is the method that actually does the work.
49 | ///
50 | /// The DA object is used to retrieve from inputs and store in outputs.
51 | protected override void SolveInstance(IGH_DataAccess DA)
52 | {
53 | IGH_Goo gooS = null;
54 | DA.GetData(0, ref gooS);
55 | if (!gooS.TryGetWorksheet(out ExWorksheet worksheet)) return;
56 |
57 | DA.SetData(0, worksheet);
58 | DA.SetDataList(1, worksheet.GetRanges());
59 | DA.SetDataList(2, worksheet.ActiveCells);
60 | }
61 |
62 | ///
63 | /// Provides an Icon for the component.
64 | ///
65 | protected override System.Drawing.Bitmap Icon
66 | {
67 | get
68 | {
69 | //You can add image files to your project resources and access them like this:
70 | // return Resources.IconForThisComponent;
71 | return Properties.Resources.XL_Wks_Deconstruct;
72 | }
73 | }
74 |
75 | ///
76 | /// Gets the unique ID for this component. Do not change this ID after release.
77 | ///
78 | public override Guid ComponentGuid
79 | {
80 | get { return new Guid("1dec7015-73fc-4501-9454-10f03c08e70c"); }
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Worksheet/GH_XL_Wks_PlaceImage.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Sd = System.Drawing;
8 |
9 | namespace ExcelPlus.Components.Worksheet
10 | {
11 | public class GH_XL_Wks_PlaceImage : GH_XL_Wks__Base
12 | {
13 | ///
14 | /// Initializes a new instance of the GH_XL_Wks_PlaceImage class.
15 | ///
16 | public GH_XL_Wks_PlaceImage()
17 | : base("Place Image", "Sht Img",
18 | "Places a bitmap image in a worksheet",
19 | Constants.ShortName, Constants.SubWorkSheets)
20 | {
21 | }
22 |
23 | ///
24 | /// Set Exposure level for the component.
25 | ///
26 | public override GH_Exposure Exposure
27 | {
28 | get { return GH_Exposure.tertiary; }
29 | }
30 |
31 | ///
32 | /// Registers all the input parameters for this component.
33 | ///
34 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
35 | {
36 | base.RegisterInputParams(pManager);
37 | pManager[0].Optional = true;
38 | pManager.AddGenericParameter("Image", "I", "The System.Drawing.Bitmap or image file path to display", GH_ParamAccess.item);
39 | pManager.AddPointParameter("Location", "L", "The location of the Shape", GH_ParamAccess.item);
40 | pManager[2].Optional = true;
41 | pManager.AddNumberParameter("Scale", "S", "A unitized scale factor (0-1) for the image", GH_ParamAccess.item, 1.0);
42 | pManager[3].Optional = true;
43 | }
44 |
45 | ///
46 | /// Registers all the output parameters for this component.
47 | ///
48 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
49 | {
50 | base.RegisterOutputParams(pManager);
51 | }
52 |
53 | ///
54 | /// This is the method that actually does the work.
55 | ///
56 | /// The DA object is used to retrieve from inputs and store in outputs.
57 | protected override void SolveInstance(IGH_DataAccess DA)
58 | {
59 | IGH_Goo gooS = null;
60 | DA.GetData(0, ref gooS);
61 | if (!gooS.TryGetWorksheet(out ExWorksheet worksheet)) return;
62 |
63 | IGH_Goo gooB = null;
64 | DA.GetData(1, ref gooB);
65 | if (!gooB.TryGetBitmap(out Sd.Bitmap bitmap, out string path)) return;
66 |
67 | Point3d location = new Point3d(0,0,0);
68 | DA.GetData(2, ref location);
69 |
70 | double scale = 1.0;
71 | DA.GetData(3, ref scale);
72 |
73 | worksheet.AddShapes(ExShape.ConstructImage(bitmap, location, scale));
74 |
75 | DA.SetData(0, worksheet);
76 | }
77 |
78 | ///
79 | /// Provides an Icon for the component.
80 | ///
81 | protected override System.Drawing.Bitmap Icon
82 | {
83 | get
84 | {
85 | //You can add image files to your project resources and access them like this:
86 | // return Resources.IconForThisComponent;
87 | return Properties.Resources.XL_Shp_Image;
88 | }
89 | }
90 |
91 | ///
92 | /// Gets the unique ID for this component. Do not change this ID after release.
93 | ///
94 | public override Guid ComponentGuid
95 | {
96 | get { return new Guid("de722794-758d-4ee5-bafb-6b1cd9eb785e"); }
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Worksheet/GH_XL_Wks_Properties.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Grasshopper.Kernel.Types;
3 | using Rhino.Geometry;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace ExcelPlus.Components
8 | {
9 | public class GH_XL_Wks_Properties : GH_XL_Wks__Base
10 | {
11 | ///
12 | /// Initializes a new instance of the GH_XL_Wks_Properties class.
13 | ///
14 | public GH_XL_Wks_Properties()
15 | : base("Worksheet Properties", "Wks Prop",
16 | "Gets or Sets Worksheet properties",
17 | Constants.ShortName, Constants.SubWorkSheets)
18 | {
19 | }
20 |
21 | ///
22 | /// Set Exposure level for the component.
23 | ///
24 | public override GH_Exposure Exposure
25 | {
26 | get { return GH_Exposure.secondary; }
27 | }
28 |
29 |
30 | ///
31 | /// Registers all the input parameters for this component.
32 | ///
33 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
34 | {
35 | base.RegisterInputParams(pManager);
36 | pManager.AddTextParameter("Name", "N", "The Worksheet name", GH_ParamAccess.item);
37 | pManager[1].Optional = true;
38 | pManager.AddBooleanParameter("Active", "A", "Flag the Worksheet as active" + Environment.NewLine + "(note: If this is true on multiple worksheets, only the last sheet in the sequence will be set to active.)", GH_ParamAccess.item);
39 | pManager[2].Optional = true;
40 | }
41 |
42 | ///
43 | /// Registers all the output parameters for this component.
44 | ///
45 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
46 | {
47 | base.RegisterOutputParams(pManager);
48 | pManager.AddTextParameter("Name", "N", "The Worksheet name", GH_ParamAccess.item);
49 | pManager.AddBooleanParameter("Active", "A", "Gets the active status of a Worksheet", GH_ParamAccess.item);
50 | }
51 |
52 | ///
53 | /// This is the method that actually does the work.
54 | ///
55 | /// The DA object is used to retrieve from inputs and store in outputs.
56 | protected override void SolveInstance(IGH_DataAccess DA)
57 | {
58 | IGH_Goo gooS = null;
59 | DA.GetData(0, ref gooS);
60 | if (!gooS.TryGetWorksheet(out ExWorksheet worksheet)) return;
61 |
62 | string name = string.Empty;
63 | if (DA.GetData(1, ref name)) worksheet.Name = name;
64 |
65 | bool active = false;
66 | if (DA.GetData(2, ref active)) worksheet.Active = active;
67 |
68 | DA.SetData(0, worksheet);
69 | DA.SetData(1, worksheet.Name);
70 | DA.SetData(2, worksheet.Active);
71 | }
72 |
73 | ///
74 | /// Provides an Icon for the component.
75 | ///
76 | protected override System.Drawing.Bitmap Icon
77 | {
78 | get
79 | {
80 | //You can add image files to your project resources and access them like this:
81 | // return Resources.IconForThisComponent;
82 | return Properties.Resources.XL_Wks_Edit;
83 | }
84 | }
85 |
86 | ///
87 | /// Gets the unique ID for this component. Do not change this ID after release.
88 | ///
89 | public override Guid ComponentGuid
90 | {
91 | get { return new Guid("77c44219-2cc1-454f-935b-06a0487b6484"); }
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/ExcelPlus/Components/Worksheet/GH_XL_Wks__Base.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 | using Rhino.Geometry;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace ExcelPlus.Components
7 | {
8 | public abstract class GH_XL_Wks__Base : GH_Component
9 | {
10 | ///
11 | /// Initializes a new instance of the GH_XL_Wks__Base class.
12 | ///
13 | public GH_XL_Wks__Base()
14 | : base("GH_XL_Wks__Base", "Nickname",
15 | "Description",
16 | "Category", "Subcategory")
17 | {
18 | }
19 |
20 | public GH_XL_Wks__Base(string Name, string NickName, string Description, string Category, string Subcategory) : base(Name, NickName, Description, Category, Subcategory)
21 | {
22 | }
23 |
24 | ///
25 | /// Registers all the input parameters for this component.
26 | ///
27 | protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
28 | {
29 | pManager.AddGenericParameter(Constants.Worksheet.Name, Constants.Worksheet.NickName, Constants.Worksheet.Input, GH_ParamAccess.item);
30 | }
31 |
32 | ///
33 | /// Registers all the output parameters for this component.
34 | ///
35 | protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
36 | {
37 | pManager.AddGenericParameter(Constants.Worksheet.Name, Constants.Worksheet.NickName, Constants.Worksheet.Output, GH_ParamAccess.item);
38 | }
39 |
40 | ///
41 | /// This is the method that actually does the work.
42 | ///
43 | /// The DA object is used to retrieve from inputs and store in outputs.
44 | protected override void SolveInstance(IGH_DataAccess DA)
45 | {
46 | }
47 |
48 | ///
49 | /// Provides an Icon for the component.
50 | ///
51 | protected override System.Drawing.Bitmap Icon
52 | {
53 | get
54 | {
55 | //You can add image files to your project resources and access them like this:
56 | // return Resources.IconForThisComponent;
57 | return null;
58 | }
59 | }
60 |
61 | ///
62 | /// Gets the unique ID for this component. Do not change this ID after release.
63 | ///
64 | public override Guid ComponentGuid
65 | {
66 | get { return new Guid("25bdb751-b9f7-40df-8158-dbc071dde8d2"); }
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/ExcelPlus/ExcelPlus.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.32002.261
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExcelPlus", "ExcelPlus.csproj", "{324C63DD-9885-47C2-8E57-67B92C5EE3E8}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {324C63DD-9885-47C2-8E57-67B92C5EE3E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {324C63DD-9885-47C2-8E57-67B92C5EE3E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {324C63DD-9885-47C2-8E57-67B92C5EE3E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {324C63DD-9885-47C2-8E57-67B92C5EE3E8}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {CBC1F072-758C-4D3D-A5DD-E96756FD492C}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ExcelPlus/ExcelPlusInfo.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper;
2 | using Grasshopper.Kernel;
3 | using System;
4 | using System.Drawing;
5 |
6 | namespace ExcelPlus
7 | {
8 | public class ExcelPlusInfo : GH_AssemblyInfo
9 | {
10 | public override string Name
11 | {
12 | get
13 | {
14 | return "ExcelPlus";
15 | }
16 | }
17 | public override Bitmap Icon
18 | {
19 | get
20 | {
21 | //Return a 24x24 pixel bitmap to represent this GHA library.
22 | return Properties.Resources.ExcelPlus_24;
23 | }
24 | }
25 | public override string Description
26 | {
27 | get
28 | {
29 | //Return a short string describing the purpose of this GHA library.
30 | return "A Grasshopper 3d plugin for Excel File Read & Write";
31 | }
32 | }
33 | public override Guid Id
34 | {
35 | get
36 | {
37 | return new Guid("963a7dc5-77f2-4125-a995-561ee3106f83");
38 | }
39 | }
40 |
41 | public override string AuthorName
42 | {
43 | get
44 | {
45 | //Return a string identifying you or your company.
46 | return "David Mans";
47 | }
48 | }
49 | public override string AuthorContact
50 | {
51 | get
52 | {
53 | //Return a string representing your preferred contact details.
54 | return "interopxyz@gmail.com";
55 | }
56 | }
57 |
58 | public override string AssemblyVersion
59 | {
60 | get
61 | {
62 | return "1.0.7.0";
63 | }
64 | }
65 | }
66 |
67 | public class ExcelPlusCategoryIcon : GH_AssemblyPriority
68 | {
69 | public object Properties { get; private set; }
70 |
71 | public override GH_LoadingInstruction PriorityLoad()
72 | {
73 | Instances.ComponentServer.AddCategoryIcon(Constants.ShortName, ExcelPlus.Properties.Resources.ExcelPlus_Tab_16);
74 | Instances.ComponentServer.AddCategorySymbolName(Constants.ShortName, 'E');
75 | return GH_LoadingInstruction.Proceed;
76 | }
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/ExcelPlus/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ExcelPlus")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Interopxyz | David Mans")]
12 | [assembly: AssemblyProduct("ExcelPlus")]
13 | [assembly: AssemblyCopyright("Copyright © 2023")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("324c63dd-9885-47c2-8e57-67b92c5ee3e8")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.7.0")]
36 | [assembly: AssemblyFileVersion("1.0.7.0")]
37 |
--------------------------------------------------------------------------------
/ExcelPlus/Resources/ExcelPlus-24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/ExcelPlus-24.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/ExcelPlus-Tab-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/ExcelPlus-Tab-16.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Cel-Add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Cel-Add.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Cel-Address.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Cel-Address.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Cel-Clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Cel-Clear.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Cel-Construct.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Cel-Construct.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Cel-GetCells2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Cel-GetCells2.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Cel-Location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Cel-Location.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Cel-Value2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Cel-Value2.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Con-Bars.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Con-Bars.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Con-Between.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Con-Between.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Con-Blank.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Con-Blank.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Con-Count.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Con-Count.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Con-Percent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Con-Percent.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Con-Scale.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Con-Scale.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Con-SparkBar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Con-SparkBar.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Con-SparkLine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Con-SparkLine.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Con-Text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Con-Text.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Con-Unique.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Con-Unique.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Con-Value.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Con-Value.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Grp-BorderHorizontal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Grp-BorderHorizontal.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Grp-BorderVertial.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Grp-BorderVertial.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Grp-Fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Grp-Fill.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Grp-Font.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Grp-Font.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Grp-Size.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Grp-Size.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Rng-Add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Rng-Add.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Rng-By.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Rng-By.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Rng-Compile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Rng-Compile.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Rng-Deconstruct.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Rng-Deconstruct.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Rng-Explode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Rng-Explode.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Rng-Extents.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Rng-Extents.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Rng-GetCell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Rng-GetCell.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Rng-GetCells.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Rng-GetCells.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Rng-Merge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Rng-Merge.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Rng-Populate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Rng-Populate.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Shp-Image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Shp-Image.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Wbk-Add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Wbk-Add.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Wbk-Deconstruct.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Wbk-Deconstruct.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Wbk-Edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Wbk-Edit.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Wbk-Open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Wbk-Open.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Wbk-Read.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Wbk-Read.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Wbk-Refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Wbk-Refresh.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Wbk-Save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Wbk-Save.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Wbk-Wrt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Wbk-Wrt.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Wks-Add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Wks-Add.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Wks-Deconstruct.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Wks-Deconstruct.png
--------------------------------------------------------------------------------
/ExcelPlus/Resources/XL-Wks-Edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interopxyz/ExcelPlus/96d6b218fa837816b09d1a54e586e0a019c15dc7/ExcelPlus/Resources/XL-Wks-Edit.png
--------------------------------------------------------------------------------
/ExcelPlus/Utilities/Constants.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | using Sd = System.Drawing;
8 |
9 | namespace ExcelPlus
10 | {
11 | public class Constants
12 | {
13 |
14 | #region naming
15 |
16 | public static string UniqueName
17 | {
18 | get { return ShortName+"_" + DateTime.UtcNow.ToString("yyyy-dd-M_HH-mm-ss"); }
19 | }
20 |
21 | public static string LongName
22 | {
23 | get { return ShortName + " v" + Major + "." + Minor; }
24 | }
25 |
26 | public static string ShortName
27 | {
28 | get { return "ExcelPlus"; }
29 | }
30 |
31 | private static string Minor
32 | {
33 | get { return typeof(Constants).Assembly.GetName().Version.Minor.ToString(); }
34 | }
35 | private static string Major
36 | {
37 | get { return typeof(Constants).Assembly.GetName().Version.Major.ToString(); }
38 | }
39 |
40 | public static string SubRange
41 | {
42 | get { return "Range"; }
43 | }
44 |
45 | public static string SubObject
46 | {
47 | get { return "Shape"; }
48 | }
49 |
50 | public static string SubCell
51 | {
52 | get { return "Cell"; }
53 | }
54 |
55 | public static string SubApp
56 | {
57 | get { return "App"; }
58 | }
59 |
60 | public static string SubData
61 | {
62 | get { return "Data"; }
63 | }
64 |
65 | public static string SubFormat
66 | {
67 | get { return "Format"; }
68 | }
69 |
70 | public static string SubChart
71 | {
72 | get { return "Chart"; }
73 | }
74 |
75 | public static string SubAnalysis
76 | {
77 | get { return "Analysis"; }
78 | }
79 |
80 | public static string SubWorkBooks
81 | {
82 | get { return "Workbook"; }
83 | }
84 |
85 | public static string SubWorkSheets
86 | {
87 | get { return "Worksheet"; }
88 | }
89 |
90 | public static Descriptor Location
91 | {
92 | get { return new Descriptor("Cell Location", "L", "Location of the cell as:"
93 | + Environment.NewLine +"String address ex. 'A1'"
94 | + Environment.NewLine+ "Domain interval ex. 1 to 1"
95 | + Environment.NewLine + "Point3d ex. {1,1,0}",
96 | "Cell location string", "Cell location string"); }
97 | }
98 |
99 | public static Descriptor Format
100 | {
101 | get {
102 | return new Descriptor("Format", "F", "MS Office Number Format"
103 | + Environment.NewLine + "Examples (\"General\", \"hh: mm:ss\", \"$#,##0.0\" )"
104 | + Environment.NewLine + "https://support.microsoft.com/en-us/office/number-format-codes-5026bbd6-04bc-48cd-bf33-80f18b4eae68?ui=en-us&rs=en-us&ad=us"
105 | ,"Cell format string", "Cell format string");
106 | }
107 | }
108 |
109 | public static Descriptor App
110 | {
111 | get { return new Descriptor("Excel Application", "App", "A Worksheet, Workbook, Range Object, Excel Application, or Text Workbook Name", "An Excel Application Object", "Excel Application Objects"); }
112 | }
113 |
114 | public static Descriptor Workbook
115 | {
116 | get { return new Descriptor("Workbook", "Wbk", "A Worksheet, Workbook, Range, or Workbook Name", "An Excel Workbook Object", "Excel Workbook Objects"); }
117 | }
118 |
119 | public static Descriptor Worksheet
120 | {
121 | get { return new Descriptor("Worksheet", "Wks", "A Worksheet, Workbook, Range, or Worksheet Name", "An Excel Worksheet Object", "Excel Worksheet Objects"); }
122 | }
123 |
124 | public static Descriptor Range
125 | {
126 | get { return new Descriptor("Range", "Rng", "A Range or Address (ex. A1:B1)", "An Excel Range Object", "Excel Range Objects"); }
127 | }
128 |
129 | public static Descriptor Cell
130 | {
131 | get { return new Descriptor("Cell", "Cel", "A Cell or Address (ex. A1)", "An Excel Cell Object", "Excel Cell Objects"); }
132 | }
133 |
134 | public static Descriptor Shape
135 | {
136 | get { return new Descriptor("Shape", "Shp", "A Smart Art, Control, or Graphical Shape", "An Excel Shape Object", "Excel Shape Objects"); }
137 | }
138 |
139 | public static Descriptor Chart
140 | {
141 | get { return new Descriptor("Chart", "Cht", "A Chart object", "A Chart object", "Chart objects"); }
142 | }
143 |
144 | public static Descriptor ShapeType
145 | {
146 | get { return new Descriptor("Shape Type", "T", "The Shape type", "The Shape type", "The Shape types"); }
147 | }
148 |
149 | public static Descriptor Boundary
150 | {
151 | get { return new Descriptor("Boundary", "B", "The Shape bounding rectangle", "The Shape bounding rectangle", "The Shape bounding rectangles"); }
152 | }
153 |
154 | public static Descriptor Activate
155 | {
156 | get { return new Descriptor("Activate", "_A", "If true, the component will be activated", "The active status of the component", "The active statuses of the component"); }
157 | }
158 |
159 | public static Descriptor DataSet
160 | {
161 | get { return new Descriptor("Data Set", "Dst", "A Data Set object", "A Data Set object", "Data Set objects"); }
162 | }
163 |
164 | #endregion
165 |
166 | #region color
167 |
168 | public static Sd.Color StartColor
169 | {
170 | get { return Sd.Color.FromArgb(99, 190, 123); }
171 | }
172 |
173 | public static Sd.Color MidColor
174 | {
175 | get { return Sd.Color.FromArgb(255, 235, 132); }
176 | }
177 |
178 | public static Sd.Color EndColor
179 | {
180 | get { return Sd.Color.FromArgb(248, 105, 107); }
181 | }
182 |
183 | #endregion
184 | }
185 |
186 | public class Descriptor
187 | {
188 | private string name = string.Empty;
189 | private string nickname = string.Empty;
190 | private string input = string.Empty;
191 | private string output = string.Empty;
192 | private string outputs = string.Empty;
193 |
194 | public Descriptor(string name, string nickname, string input, string output, string outputs)
195 | {
196 | this.name = name;
197 | this.nickname = nickname;
198 | this.input = input;
199 | this.output = output;
200 | this.outputs = outputs;
201 | }
202 |
203 | public virtual string Name
204 | {
205 | get { return name; }
206 | }
207 |
208 | public virtual string NickName
209 | {
210 | get { return nickname; }
211 | }
212 |
213 | public virtual string Input
214 | {
215 | get { return input; }
216 | }
217 |
218 | public virtual string Output
219 | {
220 | get { return output; }
221 | }
222 |
223 | public virtual string Outputs
224 | {
225 | get { return outputs; }
226 | }
227 | }
228 | }
229 |
--------------------------------------------------------------------------------
/ExcelPlus/Utilities/Helper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Text.RegularExpressions;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExcelPlus
9 | {
10 | public static class Helper
11 | {
12 | public static string GetCellAddress(int column, int row, bool absoluteColumn = false, bool absoluteRow = false)
13 | {
14 | int col = column;
15 | string colLetter = String.Empty;
16 | int mod;
17 |
18 | while (col > 0)
19 | {
20 | mod = (col - 1) % 26;
21 | colLetter = ((char)(65 + mod)).ToString() + colLetter;
22 | col = (int)((col - mod) / 26);
23 | }
24 |
25 | string ac = "";
26 | string ar = "";
27 |
28 | if (absoluteColumn) ac = "$";
29 | if (absoluteRow) ar = "$";
30 |
31 | string address = (ac + colLetter + ar + row);
32 | return address;
33 | }
34 |
35 | public static Tuple GetCellAbsolute(string address)
36 | {
37 | bool column = false;
38 | bool row = false;
39 |
40 | if (address.Count(x => x == '&') > 1)
41 | {
42 | column = true;
43 | row = true;
44 | }
45 | else if (address.Contains("$"))
46 | {
47 | char[] chars = address.ToCharArray();
48 |
49 | if (chars[0] == '$')
50 | {
51 | column = true;
52 | }
53 | else
54 | {
55 | row = true;
56 | }
57 | }
58 |
59 | return new Tuple(column, row);
60 | }
61 |
62 | public static Tuple GetCellLocation(string address)
63 | {
64 | address = address.Replace("$", "");
65 |
66 | char[] arrC = address.ToCharArray();
67 | string Lint = "";
68 | string Lstr = "";
69 | int retVal = 0;
70 |
71 | for (int i = 0; i < arrC.Length; i++)
72 | {
73 | if (char.IsNumber(arrC[i]))
74 | {
75 | Lint += arrC[i];
76 | }
77 | else
78 | {
79 | Lstr += arrC[i];
80 | }
81 | }
82 |
83 | string col = Lstr.ToUpper();
84 | int k = col.Length - 1;
85 |
86 | for (int i = 0; i < k + 1; i++)
87 | {
88 | char colPiece = col[i];
89 | int t = (int)colPiece;
90 | int colNum = t - 64;
91 | retVal = retVal + colNum * (int)(Math.Pow(26, col.Length - (i + 1)));
92 | }
93 |
94 | return new Tuple(retVal, Convert.ToInt32(Lint));
95 | }
96 |
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/ExcelPlus/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ExcelPlus/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 David Mans
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Excel +
2 | Excel file/stream read/write plugin for Grasshopper 3d
3 |
4 | _Like Excel+ [Buy me a coffee :D](http://www.buymeacoffee.com/davidmans)_
5 |
6 | ---
7 |
8 | This plugin for Grasshopper 3d makes it simple to construct and deconstruction Excel Workbooks without the need to have Excel installed. Open and Save Excel Files or Read and Write to Memory streams for compute setups or other data-focused purposes. Control the formatting of Cells, Ranges, Worksheets, and Workbooks and read/write data and formulas. Built on top of [ClosedXML](https://github.com/ClosedXML/ClosedXML)
9 |
10 | [Download Plugin at Food4Rhino](https://www.food4rhino.com/en/app/excel)
11 |
12 |
13 | ## Learn More
14 |
15 | [Plugin Documentation](https://interopxyz.gitbook.io/excel-plus/)
16 |
17 | ### Dependencies
18 | - [ClosedXML](https://github.com/ClosedXML/ClosedXML)
19 | - [Rhinoceros 3d](https://www.rhino3d.com/)
20 | - [Rhinocommon](https://www.nuget.org/packages/RhinoCommon/5.12.50810.13095)
21 |
--------------------------------------------------------------------------------