Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views-3.4.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views-3.4.csproj	(revision 11522)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views-3.4.csproj	(revision 11523)
@@ -93,4 +93,9 @@
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="EPPlus-3.1.3, Version=3.1.3.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\bin\EPPlus-3.1.3.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core">
@@ -116,4 +121,5 @@
       <DependentUpon>InteractiveSymbolicClassificationSolutionSimplifierView.cs</DependentUpon>
     </Compile>
+    <Compile Include="SymbolicDiscriminantFunctionClassificationSolutionExcelExporter.cs" />
     <Compile Include="SymbolicClassificationSolutionView.cs">
       <SubType>UserControl</SubType>
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicDiscriminantFunctionClassificationSolutionExcelExporter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicDiscriminantFunctionClassificationSolutionExcelExporter.cs	(revision 11523)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicDiscriminantFunctionClassificationSolutionExcelExporter.cs	(revision 11523)
@@ -0,0 +1,234 @@
+﻿using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.DataAnalysis.Symbolic.Views;
+using OfficeOpenXml;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views {
+  public class SymbolicDiscriminantFunctionClassificationSolutionExcelExporter : SymbolicSolutionExcelExporter {
+    protected override void ExportChart(string fileName, ISymbolicDataAnalysisSolution solution, string formula) {
+      ExportChart(fileName, solution as ISymbolicClassificationSolution, formula);
+    }
+
+    private void ExportChart(string fileName, ISymbolicClassificationSolution solution, string formula) {
+      FileInfo newFile = new FileInfo(fileName);
+      if (newFile.Exists) {
+        newFile.Delete();
+        newFile = new FileInfo(fileName);
+      }
+      var formulaParts = formula.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
+
+      using (ExcelPackage package = new ExcelPackage(newFile)) {
+        ExcelWorksheet modelWorksheet = package.Workbook.Worksheets.Add("Model");
+        FormatModelSheet(modelWorksheet, solution, formulaParts);
+
+        ExcelWorksheet datasetWorksheet = package.Workbook.Worksheets.Add("Dataset");
+        WriteDatasetToExcel(datasetWorksheet, solution.ProblemData);
+
+        ExcelWorksheet inputsWorksheet = package.Workbook.Worksheets.Add("Inputs");
+        WriteInputSheet(inputsWorksheet, datasetWorksheet, formulaParts.Skip(2), solution.ProblemData.Dataset);
+
+        ExcelWorksheet estimatedWorksheet = package.Workbook.Worksheets.Add("Estimated Values");
+        WriteEstimatedWorksheet(estimatedWorksheet, datasetWorksheet, formulaParts, solution);
+
+        ExcelWorksheet chartsWorksheet = package.Workbook.Worksheets.Add("Charts");
+        AddCharts(chartsWorksheet);
+        package.Workbook.Properties.Title = "Excel Export";
+        package.Workbook.Properties.Author = "HEAL";
+        package.Workbook.Properties.Comments = "Excel export of a symbolic data analysis solution from HeuristicLab";
+
+        package.Save();
+      }
+    }
+
+    protected void WriteEstimatedWorksheet(ExcelWorksheet estimatedWorksheet, ExcelWorksheet datasetWorksheet, string[] formulaParts, ISymbolicDataAnalysisSolution solution) {
+      WriteEstimatedWorksheet(estimatedWorksheet, datasetWorksheet, formulaParts, solution as SymbolicDiscriminantFunctionClassificationSolution);
+    }
+
+    protected override void FormatModelSheet(ExcelWorksheet modelWorksheet, ISymbolicDataAnalysisSolution solution, IEnumerable<string> formulaParts) {
+      FormatModelSheet(modelWorksheet, solution as SymbolicDiscriminantFunctionClassificationSolution, formulaParts);
+    }
+
+    private void FormatModelSheet(ExcelWorksheet modelWorksheet, SymbolicDiscriminantFunctionClassificationSolution solution, IEnumerable<string> formulaParts) {
+      int row = 1;
+      modelWorksheet.Cells[row, 1].Value = "Model";
+      modelWorksheet.Cells[row, 2].Value = solution.Name;
+
+      foreach (var part in formulaParts) {
+        modelWorksheet.Cells[row, 4].Value = part;
+        row++;
+      }
+
+      row = 2;
+      modelWorksheet.Cells[row, 1].Value = "Model Depth";
+      modelWorksheet.Cells[row, 2].Value = solution.Model.SymbolicExpressionTree.Depth;
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Model Length";
+      modelWorksheet.Cells[row, 2].Value = solution.Model.SymbolicExpressionTree.Length;
+      row += 2;
+
+      var thresholds = solution.Model.Thresholds.ToList();
+      // skip first (-inf) and last (+inf) thresholds
+      for (int i = 0; i < thresholds.Count; ++i) {
+        if (double.IsInfinity(thresholds[i]) || double.IsNaN(thresholds[i]))
+          continue;
+        modelWorksheet.Cells[row, 1].Value = "Threshold " + i;
+        modelWorksheet.Cells[row, 2].Value = thresholds[i];
+        ++row;
+      }
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Estimation Limits Lower";
+      modelWorksheet.Cells[row, 2].Value = Math.Max(solution.Model.LowerEstimationLimit, -9.99999999999999E+307); // minimal value supported by excel
+      modelWorksheet.Names.Add("EstimationLimitLower", modelWorksheet.Cells[row, 2]);
+      modelWorksheet.Cells[row, 2].Style.Numberformat.Format = "0.000E+00";
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Estimation Limits Upper";
+      modelWorksheet.Cells[row, 2].Value = Math.Min(solution.Model.UpperEstimationLimit, 9.99999999999999E+307);  // maximal value supported by excel
+      modelWorksheet.Names.Add("EstimationLimitUpper", modelWorksheet.Cells[row, 2]);
+      modelWorksheet.Cells[row, 2].Style.Numberformat.Format = "0.000E+00";
+      row += 2;
+
+      modelWorksheet.Cells[row, 1].Value = "Trainings Partition Start";
+      modelWorksheet.Cells[row, 2].Value = solution.ProblemData.TrainingPartition.Start;
+      modelWorksheet.Names.Add(TRAININGSTART, modelWorksheet.Cells[row, 2]);
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Trainings Partition End";
+      modelWorksheet.Cells[row, 2].Value = solution.ProblemData.TrainingPartition.End;
+      modelWorksheet.Names.Add(TRAININGEND, modelWorksheet.Cells[row, 2]);
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Test Partition Start";
+      modelWorksheet.Cells[row, 2].Value = solution.ProblemData.TestPartition.Start;
+      modelWorksheet.Names.Add(TESTSTART, modelWorksheet.Cells[row, 2]);
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Test Partition End";
+      modelWorksheet.Cells[row, 2].Value = solution.ProblemData.TestPartition.End;
+      modelWorksheet.Names.Add(TESTEND, modelWorksheet.Cells[row, 2]);
+      row += 2;
+
+      string excelTrainingTarget = Indirect("B", true);
+      string excelTrainingEstimated = Indirect("C", true);
+      string excelTrainingClassValues = Indirect("D", true);
+      string excelTrainingMeanError = Indirect("F", true);
+      string excelTrainingMSE = Indirect("G", true);
+
+      string excelTestTarget = Indirect("B", false);
+      string excelTestEstimated = Indirect("C", false);
+      string excelTestClassValues = Indirect("D", false);
+      string excelTestMeanError = Indirect("F", false);
+      string excelTestMSE = Indirect("G", false);
+
+      modelWorksheet.Cells[row, 1].Value = "Accuracy (training)";
+      modelWorksheet.Cells[row, 2].Formula = string.Format("SUMPRODUCT(({0}={1})*1)/COUNT({0})", excelTrainingClassValues, excelTrainingTarget);
+      modelWorksheet.Cells[row, 2].Style.Numberformat.Format = "0.000";
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Accuracy (test)";
+      modelWorksheet.Cells[row, 2].Formula = string.Format("SUMPRODUCT(({0}={1})*1)/COUNT({0})", excelTestClassValues, excelTestTarget);
+      modelWorksheet.Cells[row, 2].Style.Numberformat.Format = "0.000";
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Pearson's R² (training)";
+      modelWorksheet.Cells[row, 2].Formula = string.Format("POWER(PEARSON({0},{1}),2)", excelTrainingTarget, excelTrainingEstimated);
+      modelWorksheet.Cells[row, 2].Style.Numberformat.Format = "0.000";
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Pearson's R² (test)";
+      modelWorksheet.Cells[row, 2].Formula = string.Format("POWER(PEARSON({0},{1}),2)", excelTestTarget, excelTestEstimated);
+      modelWorksheet.Cells[row, 2].Style.Numberformat.Format = "0.000";
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Mean Squared Error (training)";
+      modelWorksheet.Cells[row, 2].Formula = string.Format("AVERAGE({0})", excelTrainingMSE);
+      modelWorksheet.Names.Add("TrainingMSE", modelWorksheet.Cells[row, 2]);
+      modelWorksheet.Cells[row, 2].Style.Numberformat.Format = "0.000E+00";
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Mean Squared Error (test)";
+      modelWorksheet.Cells[row, 2].Formula = string.Format("AVERAGE({0})", excelTestMSE);
+      modelWorksheet.Names.Add("TestMSE", modelWorksheet.Cells[row, 2]);
+      modelWorksheet.Cells[row, 2].Style.Numberformat.Format = "0.000E+00";
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Normalized Gini Coefficient (training)";
+      modelWorksheet.Cells[row, 2].Formula = string.Format("AVERAGE({0})", excelTrainingMeanError);
+      modelWorksheet.Cells[row, 2].Style.Numberformat.Format = "0.000E+00";
+      row++;
+
+      modelWorksheet.Cells[row, 1].Value = "Normalized Gini Coefficient (test)";
+      modelWorksheet.Cells[row, 2].Formula = string.Format("AVERAGE({0})", excelTestMeanError);
+      modelWorksheet.Cells[row, 2].Style.Numberformat.Format = "0.000E+00";
+      row++;
+
+      modelWorksheet.Cells["A1:B" + row].AutoFitColumns();
+
+      AddModelTreePicture(modelWorksheet, solution.Model);
+    }
+
+    private void WriteEstimatedWorksheet(ExcelWorksheet estimatedWorksheet, ExcelWorksheet datasetWorksheet, string[] formulaParts, SymbolicDiscriminantFunctionClassificationSolution solution) {
+      string preparedFormula = PrepareFormula(formulaParts);
+      int rows = solution.ProblemData.Dataset.Rows;
+      estimatedWorksheet.Cells[1, 1].Value = "Id"; // A
+      estimatedWorksheet.Cells[1, 2].Value = "Target Variable"; // B
+      estimatedWorksheet.Cells[1, 3].Value = "Estimated Values"; // C
+      estimatedWorksheet.Cells[1, 4].Value = "Estimated Class Values"; // D
+      estimatedWorksheet.Cells[1, 6].Value = "Error"; // E
+      estimatedWorksheet.Cells[1, 7].Value = "Squared Error"; // G
+      estimatedWorksheet.Cells[1, 9].Value = "Unbounded Estimated Values"; // I
+      estimatedWorksheet.Cells[1, 10].Value = "Bounded Estimated Values"; // J
+
+      estimatedWorksheet.Cells[1, 1, 1, 10].AutoFitColumns();
+
+      var thresholds = solution.Model.Thresholds.Where(x => !double.IsInfinity(x)).ToList();
+      var thresholdsFormula = GenerateThresholdsFormula(thresholds);
+
+      int targetIndex = solution.ProblemData.Dataset.VariableNames.ToList().FindIndex(x => x.Equals(solution.ProblemData.TargetVariable)) + 1;
+      for (int i = 0; i < rows; i++) {
+        estimatedWorksheet.Cells[i + 2, 1].Value = i;
+        estimatedWorksheet.Cells[i + 2, 2].Formula = datasetWorksheet.Cells[i + 2, targetIndex].FullAddress; // target values
+        estimatedWorksheet.Cells[i + 2, 9].Formula = string.Format(preparedFormula, i + 2); // formula (estimated) values
+      }
+      estimatedWorksheet.Cells["B2:B" + (rows + 1)].Style.Numberformat.Format = "0.000";
+
+      estimatedWorksheet.Cells["C2:C" + (rows + 1)].Formula = "J2";
+      estimatedWorksheet.Cells["C2:C" + (rows + 1)].Style.Numberformat.Format = "0.000";
+
+      estimatedWorksheet.Cells["D2:D" + (rows + 1)].Formula = thresholdsFormula;
+      estimatedWorksheet.Cells["D2:D" + (rows + 1)].Style.Numberformat.Format = "0.0";
+
+      estimatedWorksheet.Cells["F2:F" + (rows + 1)].Formula = "B2 - D2";
+      estimatedWorksheet.Cells["F2:F" + (rows + 1)].Style.Numberformat.Format = "0.0";
+
+      estimatedWorksheet.Cells["G2:G" + (rows + 1)].Formula = "POWER(F2, 2)";
+      estimatedWorksheet.Cells["G2:G" + (rows + 1)].Style.Numberformat.Format = "0.000";
+
+      estimatedWorksheet.Cells["I2:I" + (rows + 1)].Style.Numberformat.Format = "0.000";
+      estimatedWorksheet.Cells["J2:J" + (rows + 1)].Formula = "IFERROR(IF(I2 > Model!EstimationLimitUpper, Model!EstimationLimitUpper, IF(I2 < Model!EstimationLimitLower, Model!EstimationLimitLower, I2)), AVERAGE(Model!EstimationLimitLower, Model!EstimationLimitUpper))";
+      estimatedWorksheet.Cells["J2:J" + (rows + 1)].Style.Numberformat.Format = "0.000";
+    }
+
+    // this method assumes that the thresholds list is sorted in ascending order
+    private string GenerateThresholdsFormula(List<double> thresholds) {
+      if (thresholds.Count == 1) {
+        return String.Format("IF(J2 < {0}, 0, 1)", thresholds[0]);
+      }
+      var sb = new StringBuilder();
+      sb.Append(String.Format("IF(J2 < {0}, 0,", thresholds[0]));
+      for (int i = 1; i < thresholds.Count; ++i) {
+        double v = thresholds[i];
+        sb.Append(String.Format("IF(J2 < {0}, {1},", v, i));
+      }
+      for (int i = 1; i < thresholds.Count; ++i)
+        sb.Append(")");
+      sb.Append(")");
+      return sb.ToString();
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicDiscriminantFunctionClassificationSolutionView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicDiscriminantFunctionClassificationSolutionView.cs	(revision 11522)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicDiscriminantFunctionClassificationSolutionView.cs	(revision 11523)
@@ -25,5 +25,4 @@
 using System.Windows.Forms;
 using HeuristicLab.MainForm;
-using HeuristicLab.Problems.DataAnalysis.Symbolic.Views;
 using HeuristicLab.Problems.DataAnalysis.Views;
 
@@ -54,5 +53,5 @@
 
     private void exportButton_Click(object sender, EventArgs e) {
-      var exporter = new SymbolicSolutionExcelExporter();
+      var exporter = new SymbolicDiscriminantFunctionClassificationSolutionExcelExporter();
       exportFileDialog.Filter = exporter.FileTypeFilter;
       if (exportFileDialog.ShowDialog(this) == DialogResult.OK) {
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Exporters/SymbolicSolutionExcelExporter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Exporters/SymbolicSolutionExcelExporter.cs	(revision 11522)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Exporters/SymbolicSolutionExcelExporter.cs	(revision 11523)
@@ -30,8 +30,8 @@
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
   public class SymbolicSolutionExcelExporter : IDataAnalysisSolutionExporter {
-    private const string TRAININGSTART = "TrainingStart";
-    private const string TRAININGEND = "TrainingEnd";
-    private const string TESTSTART = "TestStart";
-    private const string TESTEND = "TestEnd";
+    protected const string TRAININGSTART = "TrainingStart";
+    protected const string TRAININGEND = "TrainingEnd";
+    protected const string TESTSTART = "TestStart";
+    protected const string TESTEND = "TestEnd";
 
 
@@ -52,5 +52,5 @@
     }
 
-    private void ExportChart(string fileName, ISymbolicDataAnalysisSolution solution, string formula) {
+    protected virtual void ExportChart(string fileName, ISymbolicDataAnalysisSolution solution, string formula) {
       FileInfo newFile = new FileInfo(fileName);
       if (newFile.Exists) {
@@ -85,5 +85,5 @@
     }
 
-    private void FormatModelSheet(ExcelWorksheet modelWorksheet, ISymbolicDataAnalysisSolution solution, IEnumerable<string> formulaParts) {
+    protected virtual void FormatModelSheet(ExcelWorksheet modelWorksheet, ISymbolicDataAnalysisSolution solution, IEnumerable<string> formulaParts) {
       int row = 1;
       modelWorksheet.Cells[row, 1].Value = "Model";
@@ -216,5 +216,5 @@
     }
 
-    private string Indirect(string column, bool training) {
+    protected string Indirect(string column, bool training) {
       if (training) {
         return string.Format("INDIRECT(\"'Estimated Values'!{0}\"&{1}+2&\":{0}\"&{2}+1)", column, TRAININGSTART, TRAININGEND);
@@ -224,5 +224,5 @@
     }
 
-    private void AddCharts(ExcelWorksheet chartsWorksheet) {
+    protected virtual void AddCharts(ExcelWorksheet chartsWorksheet) {
       chartsWorksheet.Names.AddFormula("AllId", "OFFSET('Estimated Values'!$A$1,1,0, COUNTA('Estimated Values'!$A:$A)-1)");
       chartsWorksheet.Names.AddFormula("AllTarget", "OFFSET('Estimated Values'!$B$1,1,0, COUNTA('Estimated Values'!$B:$B)-1)");
@@ -260,5 +260,5 @@
     }
 
-    private void AddModelTreePicture(ExcelWorksheet modelWorksheet, ISymbolicDataAnalysisModel model) {
+    protected virtual void AddModelTreePicture(ExcelWorksheet modelWorksheet, ISymbolicDataAnalysisModel model) {
       SymbolicExpressionTreeChart modelTreePicture = new SymbolicExpressionTreeChart();
       modelTreePicture.Tree = model.SymbolicExpressionTree;
@@ -289,9 +289,10 @@
       estimatedWorksheet.Cells[1, 1, 1, 10].AutoFitColumns();
 
+      // fill in id, target variable and unbounded estimated values
       int targetIndex = solution.ProblemData.Dataset.VariableNames.ToList().FindIndex(x => x.Equals(solution.ProblemData.TargetVariable)) + 1;
       for (int i = 0; i < rows; i++) {
-        estimatedWorksheet.Cells[i + 2, 1].Value = i;
-        estimatedWorksheet.Cells[i + 2, 2].Formula = datasetWorksheet.Cells[i + 2, targetIndex].FullAddress;
-        estimatedWorksheet.Cells[i + 2, 9].Formula = string.Format(preparedFormula, i + 2);
+        estimatedWorksheet.Cells[i + 2, 1].Value = i; // id
+        estimatedWorksheet.Cells[i + 2, 2].Formula = datasetWorksheet.Cells[i + 2, targetIndex].FullAddress; // target variable
+        estimatedWorksheet.Cells[i + 2, 9].Formula = string.Format(preparedFormula, i + 2); // unbounded estimated values
       }
       estimatedWorksheet.Cells["B2:B" + (rows + 1)].Style.Numberformat.Format = "0.000";
@@ -313,5 +314,5 @@
     }
 
-    private string PrepareFormula(string[] formulaParts) {
+    protected string PrepareFormula(string[] formulaParts) {
       string preparedFormula = formulaParts[0];
       foreach (var part in formulaParts.Skip(2)) {
@@ -323,5 +324,5 @@
     }
 
-    private void WriteInputSheet(ExcelWorksheet inputsWorksheet, ExcelWorksheet datasetWorksheet, IEnumerable<string> list, Dataset dataset) {
+    protected void WriteInputSheet(ExcelWorksheet inputsWorksheet, ExcelWorksheet datasetWorksheet, IEnumerable<string> list, Dataset dataset) {
       //remark the performance of EPPlus drops dramatically 
       //if the data is not written row wise (from left to right) due the internal indices used.
@@ -337,5 +338,5 @@
     }
 
-    private void WriteDatasetToExcel(ExcelWorksheet datasetWorksheet, IDataAnalysisProblemData problemData) {
+    protected void WriteDatasetToExcel(ExcelWorksheet datasetWorksheet, IDataAnalysisProblemData problemData) {
       //remark the performance of EPPlus drops dramatically 
       //if the data is not written row wise (from left to right) due the internal indices used.
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs	(revision 11522)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs	(revision 11523)
@@ -203,4 +203,60 @@
         stringBuilder.Append(FormatRecursively(node.GetSubtree(1)));
         stringBuilder.Append(",0))");
+      } else if (symbol is IfThenElse) {
+        stringBuilder.Append("IF(");
+        stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + " ) > 0");
+        stringBuilder.Append(",");
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(1)));
+        stringBuilder.Append(",");
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(2)));
+        stringBuilder.Append(")");
+      } else if (symbol is VariableCondition) {
+        VariableConditionTreeNode variableConditionTreeNode = node as VariableConditionTreeNode;
+        double threshold = variableConditionTreeNode.Threshold;
+        double slope = variableConditionTreeNode.Slope;
+        string p = "(1 / (1 + EXP(-" + slope.ToString(CultureInfo.InvariantCulture) + "* (" + GetColumnToVariableName(variableConditionTreeNode.VariableName) + "-" + threshold.ToString(CultureInfo.InvariantCulture) + "))))";
+        stringBuilder.Append("INT((");
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
+        stringBuilder.Append("*");
+        stringBuilder.Append(p);
+        stringBuilder.Append(") + (");
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(1)));
+        stringBuilder.Append("*(");
+        stringBuilder.Append("1 - " + p + ")");
+        stringBuilder.Append("))");
+      } else if (symbol is Xor) {
+        stringBuilder.Append("IF(");
+        stringBuilder.Append("XOR(");
+        stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + ") > 0,");
+        stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(1)) + ") > 0");
+        stringBuilder.Append("), 1.0, -1.0)");
+      } else if (symbol is Or) {
+        stringBuilder.Append("IF(");
+        stringBuilder.Append("OR(");
+        stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + ") > 0,");
+        stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(1)) + ") > 0");
+        stringBuilder.Append("), 1.0, -1.0)");
+      } else if (symbol is And) {
+        stringBuilder.Append("IF(");
+        stringBuilder.Append("AND(");
+        stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + ") > 0,");
+        stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(1)) + ") > 0");
+        stringBuilder.Append("), 1.0, -1.0)");
+      } else if (symbol is Not) {
+        stringBuilder.Append("IF(");
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
+        stringBuilder.Append(" > 0, -1.0, 1.0)");
+      } else if (symbol is GreaterThan) {
+        stringBuilder.Append("IF((");
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
+        stringBuilder.Append(") > (");
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(1)));
+        stringBuilder.Append("), 1.0, -1.0)");
+      } else if (symbol is LessThan) {
+        stringBuilder.Append("IF((");
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
+        stringBuilder.Append(") < (");
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(1)));
+        stringBuilder.Append("), 1.0, -1.0)");
       } else {
         throw new NotImplementedException("Excel export of " + node.Symbol + " is not implemented.");
