@@ -89,6 +89,7 @@ public function testFormulaWithOptionalArgumentsAndRequiredCellReferenceShouldPa
89
89
$ cell = $ sheet ->getCell ('F6 ' );
90
90
$ cell ->setValue ('=OFFSET(D3, -1, -2) ' );
91
91
self ::assertEquals (5 , $ cell ->getCalculatedValue (), 'missing arguments should be filled with null ' );
92
+ $ spreadsheet ->disconnectWorksheets ();
92
93
}
93
94
94
95
public function testCellSetAsQuotedText (): void
@@ -103,18 +104,27 @@ public function testCellSetAsQuotedText(): void
103
104
self ::assertEquals ("=cmd|'/C calc'!A0 " , $ cell ->getCalculatedValue ());
104
105
105
106
$ cell2 = $ workSheet ->getCell ('A2 ' );
107
+ $ cell2 ->setValueExplicit ('ABC ' , DataType::TYPE_FORMULA );
108
+ self ::assertEquals ('ABC ' , $ cell2 ->getCalculatedValue ());
109
+
110
+ $ cell3 = $ workSheet ->getCell ('A3 ' );
111
+ $ cell3 ->setValueExplicit ('= ' , DataType::TYPE_FORMULA );
112
+ self ::assertEquals ('' , $ cell3 ->getCalculatedValue ());
113
+
114
+ $ cell4 = $ workSheet ->getCell ('A4 ' );
106
115
107
116
try {
108
- $ cell2 ->setValueExplicit ('ABC ' , DataType::TYPE_FORMULA );
109
- self ::assertEquals ('ABC ' , $ cell2 ->getCalculatedValue ());
110
- self ::fail ('setValueExplicit with invalid formula should have thrown exception ' );
117
+ $ cell4 ->setValueExplicit ((object ) null , DataType::TYPE_FORMULA );
118
+ self ::fail ('setValueExplicit formula with unstringable object should have thrown exception ' );
111
119
} catch (SpreadsheetException $ e ) {
112
- self ::assertStringContainsString ('Invalid value for datatype Formula ' , $ e ->getMessage ());
120
+ self ::assertStringContainsString ('Invalid unstringable value for datatype Formula ' , $ e ->getMessage ());
113
121
}
114
122
115
- $ cell3 = $ workSheet ->getCell ('A3 ' );
116
- $ cell3 ->setValueExplicit ('= ' , DataType::TYPE_FORMULA );
117
- self ::assertEquals ('' , $ cell3 ->getCalculatedValue ());
123
+ $ cell5 = $ workSheet ->getCell ('A5 ' );
124
+ $ cell5 ->setValueExplicit (null , DataType::TYPE_FORMULA );
125
+ self ::assertEquals ('' , $ cell5 ->getCalculatedValue ());
126
+
127
+ $ spreadsheet ->disconnectWorksheets ();
118
128
}
119
129
120
130
public function testCellWithDdeExpresion (): void
@@ -126,6 +136,7 @@ public function testCellWithDdeExpresion(): void
126
136
$ cell ->setValue ("=cmd|'/C calc'!A0 " );
127
137
128
138
self ::assertEquals ("=cmd|'/C calc'!A0 " , $ cell ->getCalculatedValue ());
139
+ $ spreadsheet ->disconnectWorksheets ();
129
140
}
130
141
131
142
public function testFormulaReferencingWorksheetWithEscapedApostrophe (): void
@@ -144,6 +155,7 @@ public function testFormulaReferencingWorksheetWithEscapedApostrophe(): void
144
155
145
156
$ cellValue = $ workSheet ->getCell ('A2 ' )->getCalculatedValue ();
146
157
self ::assertSame ('HELLO WORLD ' , $ cellValue );
158
+ $ spreadsheet ->disconnectWorksheets ();
147
159
}
148
160
149
161
public function testFormulaReferencingWorksheetWithUnescapedApostrophe (): void
@@ -162,6 +174,7 @@ public function testFormulaReferencingWorksheetWithUnescapedApostrophe(): void
162
174
163
175
$ cellValue = $ workSheet ->getCell ('A2 ' )->getCalculatedValue ();
164
176
self ::assertSame ('HELLO WORLD ' , $ cellValue );
177
+ $ spreadsheet ->disconnectWorksheets ();
165
178
}
166
179
167
180
public function testCellWithFormulaTwoIndirect (): void
@@ -178,6 +191,7 @@ public function testCellWithFormulaTwoIndirect(): void
178
191
$ cell3 ->setValue ('=SUM(INDIRECT("A"&ROW()),INDIRECT("B"&ROW()),INDIRECT("C"&ROW())) ' );
179
192
180
193
self ::assertEquals ('9 ' , $ cell3 ->getCalculatedValue ());
194
+ $ spreadsheet ->disconnectWorksheets ();
181
195
}
182
196
183
197
public function testCellWithStringNumeric (): void
@@ -190,6 +204,7 @@ public function testCellWithStringNumeric(): void
190
204
$ cell2 ->setValue ('=100*A1 ' );
191
205
192
206
self ::assertSame (250.0 , $ cell2 ->getCalculatedValue ());
207
+ $ spreadsheet ->disconnectWorksheets ();
193
208
}
194
209
195
210
public function testCellWithStringFraction (): void
@@ -202,6 +217,7 @@ public function testCellWithStringFraction(): void
202
217
$ cell2 ->setValue ('=100*A1 ' );
203
218
204
219
self ::assertSame (75.0 , $ cell2 ->getCalculatedValue ());
220
+ $ spreadsheet ->disconnectWorksheets ();
205
221
}
206
222
207
223
public function testCellWithStringPercentage (): void
@@ -214,6 +230,7 @@ public function testCellWithStringPercentage(): void
214
230
$ cell2 ->setValue ('=100*A1 ' );
215
231
216
232
self ::assertSame (2.0 , $ cell2 ->getCalculatedValue ());
233
+ $ spreadsheet ->disconnectWorksheets ();
217
234
}
218
235
219
236
public function testCellWithStringCurrency (): void
@@ -228,6 +245,7 @@ public function testCellWithStringCurrency(): void
228
245
$ cell2 ->setValue ('=100*A1 ' );
229
246
230
247
self ::assertSame (200.0 , $ cell2 ->getCalculatedValue ());
248
+ $ spreadsheet ->disconnectWorksheets ();
231
249
}
232
250
233
251
public function testBranchPruningFormulaParsingSimpleCase (): void
@@ -400,6 +418,7 @@ public function testFullExecutionDataPruning(
400
418
$ calculation ->disableBranchPruning ();
401
419
$ calculated = $ cell ->getCalculatedValue ();
402
420
self ::assertEquals ($ expectedResult , $ calculated );
421
+ $ spreadsheet ->disconnectWorksheets ();
403
422
}
404
423
405
424
public static function dataProviderBranchPruningFullExecution (): array
0 commit comments