Remove string concatentations from long worksheet formulas that are exported by Google Sheets.
diff --git a/EPPlus/ExcelWorksheet.cs b/EPPlus/ExcelWorksheet.cs
index ea64e83..982c081 100644
--- a/EPPlus/ExcelWorksheet.cs
+++ b/EPPlus/ExcelWorksheet.cs
@@ -122,6 +122,7 @@
public static string RemoveDummyFunction(string formula)
{
+ const string DummyFunctionConcatenate = "\"&\"";
const string DummyFunctionPrefix = "IFERROR(__xludf.DUMMYFUNCTION(\"";
const string DummyFunctionSuffix = "\"),\"";
@@ -143,6 +144,13 @@
// Trim Prefix
formula = formula.Replace(DummyFunctionPrefix, "");
+ // Remove string concatentations from long formulas.
+ // Google break the quoted string into 254 character segments which are concatenated.
+ if (formula.Length >= 254)
+ {
+ formula = formula.Replace(DummyFunctionConcatenate, "");
+ }
+
// Replace doubled quotes with single quote
formula = formula.Replace("\"\"", "\"");