File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -307,10 +307,17 @@ public function writeFormula(string $value): void
307307 throw new XlsxFastEditorXmlException ("Internal error accessing cell {$ this ->name ()}! " );
308308 }
309309 try {
310- $ f = $ dom ->createElement ('f ' , $ value );
311- if (!($ f instanceof \DOMElement)) {
310+ // First, we create an empty element t
311+ $ f = $ dom ->createElement ('f ' );
312+ if ($ f === false ) {
312313 throw new XlsxFastEditorXmlException ("Error creating DOMElement of formula for cell {$ this ->name ()}! " );
313314 }
315+ // Add content as a text node
316+ $ textNode = $ dom ->createTextNode ($ value );
317+ if ($ textNode === false ) {
318+ throw new XlsxFastEditorXmlException ("Error creating text node of formula for cell {$ this ->name ()}! " );
319+ }
320+ $ f ->appendChild ($ textNode );
314321 } catch (\DOMException $ dex ) {
315322 throw new XlsxFastEditorXmlException ("Error creating formula for cell {$ this ->name ()}! " , $ dex ->code , $ dex );
316323 }
You can’t perform that action at this time.
0 commit comments