File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,28 @@ public void saveDataToSheet(int sheetIndex)
149
149
150
150
}
151
151
152
+ public void AddFormulaToCell ( string cellRef , UInt32 rowIndex , string formula )
153
+ {
154
+
155
+ DocumentFormat . OpenXml . Spreadsheet . Row row = new DocumentFormat . OpenXml . Spreadsheet . Row ( )
156
+ {
157
+ RowIndex = rowIndex
158
+ } ;
159
+
160
+ // Create the CellFormula element
161
+ CellFormula cellFormula = new CellFormula
162
+ {
163
+ CalculateCell = true ,
164
+ Text = formula
165
+ } ;
166
+ DocumentFormat . OpenXml . Spreadsheet . Cell cell = new DocumentFormat . OpenXml . Spreadsheet . Cell ( )
167
+ {
168
+ CellReference = cellRef ,
169
+ CellFormula = cellFormula
170
+ } ;
171
+ row . Append ( cell ) ;
172
+ sheetData . sheetData . Append ( row ) ;
173
+ }
152
174
153
175
private static List < UInt32 > AddStyle ( ref Stylesheet stylesheet )
154
176
{
You can’t perform that action at this time.
0 commit comments