Daniel Blois
Daniel Blois

Reputation: 197

ClosedXML Adding Formula creates unreadable content

I am adding a formula to worksheet using C# closedxml but it is coming back as unreadable content. I think the reason is the slashed that I added to the formula but I need the slashes to escape the quotes because I need the quotes in the formula. How else can I do this?

Here is my code:

CodeWorksheet.Range(CodeWorksheet.Cell(2, 25).Address, CodeWorksheet.Cell(CodeWorksheet.LastRowUsed().RowNumber(), 25).Address).FormulaR1C1 = "=IF(SUM(RC[-6]:RC[-1])>0,\" + \",\")";

Upvotes: 2

Views: 692

Answers (1)

UndeadBob
UndeadBob

Reputation: 1129

I think you only have one double quote in the "if false" part of your formula. Try changing

=IF(SUM(RC[-6]:RC[-1])>0,\" + \",\")

to

=IF(SUM(RC[-6]:RC[-1])>0,\" + \",\"\")

Upvotes: 1

Related Questions