Index: trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ControlExtensions.cs
===================================================================
--- trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ControlExtensions.cs	(revision 9624)
+++ trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ControlExtensions.cs	(revision 9626)
@@ -21,4 +21,5 @@
 
 using System;
+using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using System.Windows.Forms;
@@ -45,4 +46,19 @@
       }
     }
+
+    public static IEnumerable<Control> GetNestedControls(this Control control, Func<Control, bool> condition = null) {
+      if (control == null) yield break;
+      if (condition == null) condition = (c) => true;
+
+      Queue<Control> unprocessed = new Queue<Control>();
+      unprocessed.Enqueue(control);
+
+      while (unprocessed.Count > 0) {
+        Control c = unprocessed.Dequeue();
+        if (condition(c)) yield return c;
+        foreach (Control child in c.Controls)
+          unprocessed.Enqueue(child);
+      }
+    }
   }
 }
Index: trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
===================================================================
--- trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs	(revision 9624)
+++ trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs	(revision 9626)
@@ -386,4 +386,5 @@
       ToolStripMenuItem item = new ToolStripMenuItem();
       this.SetToolStripItemProperties(item, menuItem);
+      this.InsertItem(menuItem.Structure, typeof(ToolStripMenuItem), item, menuStrip.Items);
       if (menuItem is MenuItem) {
         MenuItem menuItemBase = (MenuItem)menuItem;
@@ -392,5 +393,4 @@
         item.DisplayStyle = menuItemBase.ToolStripItemDisplayStyle;
       }
-      this.InsertItem(menuItem.Structure, typeof(ToolStripMenuItem), item, menuStrip.Items);
     }
 
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/MenuItems/ExportSymbolicSolutionToExcelMenuItem.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/MenuItems/ExportSymbolicSolutionToExcelMenuItem.cs	(revision 9624)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/MenuItems/ExportSymbolicSolutionToExcelMenuItem.cs	(revision 9626)
@@ -22,4 +22,5 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.IO;
 using System.Linq;
@@ -27,4 +28,5 @@
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
 using HeuristicLab.MainForm;
+using HeuristicLab.MainForm.WindowsForms;
 using HeuristicLab.Optimizer;
 using OfficeOpenXml;
@@ -52,17 +54,28 @@
 
     protected override void OnToolStripItemSet(EventArgs e) {
+      base.OnToolStripItemSet(e);
       ToolStripItem.Enabled = false;
-    }
-    protected override void OnActiveViewChanged(object sender, EventArgs e) {
+      var menuItem = ToolStripItem.OwnerItem as ToolStripMenuItem;
+      if (menuItem != null)
+        menuItem.DropDownOpening += menuItem_DropDownOpening;
+    }
+
+    private void menuItem_DropDownOpening(object sender, EventArgs e) {
       IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
-      ToolStripItem.Enabled = activeView != null && activeView.Content is ISymbolicDataAnalysisSolution;
+      Control control = activeView as Control;
+      activeView = control.GetNestedControls((c) => c.Visible)
+        .OfType<IContentView>().FirstOrDefault(v => v.Content is ISymbolicDataAnalysisSolution && v.Content is IRegressionSolution);
+      ToolStripItem.Enabled = activeView != null;
     }
 
     public override void Execute() {
-      var activeView = (IContentView)MainFormManager.MainForm.ActiveView;
+      IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
+      Control control = activeView as Control;
+      activeView = control.GetNestedControls((c) => c.Visible)
+        .OfType<IContentView>().First(v => v.Content is ISymbolicDataAnalysisSolution && v.Content is IRegressionSolution);
       var solution = (ISymbolicDataAnalysisSolution)activeView.Content;
       var formatter = new SymbolicDataAnalysisExpressionExcelFormatter();
-      var formula = formatter.Format(solution.Model.SymbolicExpressionTree);
-      var formulaParts = formula.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
+      var formula = formatter.Format(solution.Model.SymbolicExpressionTree, solution.ProblemData.Dataset);
+
 
       SaveFileDialog saveFileDialog = new SaveFileDialog();
@@ -71,32 +84,41 @@
       if (saveFileDialog.ShowDialog() == DialogResult.OK) {
         string fileName = saveFileDialog.FileName;
-        FileInfo newFile = new FileInfo(fileName);
-        if (newFile.Exists) {
-          newFile.Delete();
-          newFile = new FileInfo(fileName);
+        using (BackgroundWorker bg = new BackgroundWorker()) {
+          bg.DoWork += (b, e) => ExportChart(fileName, solution, formula);
+          bg.RunWorkerAsync();
         }
-        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);
-
-          if (solution is IRegressionSolution) {
-            ExcelWorksheet estimatedWorksheet = package.Workbook.Worksheets.Add("Estimated Values");
-            WriteEstimatedWorksheet(estimatedWorksheet, datasetWorksheet, formulaParts, solution as IRegressionSolution);
-
-            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();
+      }
+    }
+
+    private void ExportChart(string fileName, ISymbolicDataAnalysisSolution 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);
+
+        if (solution is IRegressionSolution) {
+          ExcelWorksheet estimatedWorksheet = package.Workbook.Worksheets.Add("Estimated Values");
+          WriteEstimatedWorksheet(estimatedWorksheet, datasetWorksheet, formulaParts, solution as IRegressionSolution);
+
+          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();
       }
     }
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs	(revision 9624)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs	(revision 9626)
@@ -23,4 +23,5 @@
 using System.Collections.Generic;
 using System.Globalization;
+using System.Linq;
 using System.Text;
 using HeuristicLab.Common;
@@ -66,9 +67,15 @@
       return string.Format("${0}1", variableNameMapping[variabelName]);
     }
-
     public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
+      return Format(symbolicExpressionTree, null);
+    }
+
+    public string Format(ISymbolicExpressionTree symbolicExpressionTree, Dataset dataset) {
       var stringBuilder = new StringBuilder();
+      if (dataset != null) CalculateVariableMapping(symbolicExpressionTree, dataset);
+
       stringBuilder.Append("=");
       stringBuilder.Append(FormatRecursively(symbolicExpressionTree.Root));
+
       foreach (var variable in variableNameMapping) {
         stringBuilder.AppendLine();
@@ -76,4 +83,16 @@
       }
       return stringBuilder.ToString();
+    }
+
+    private void CalculateVariableMapping(ISymbolicExpressionTree tree, Dataset dataset) {
+      int columnIndex = 0;
+      int inputIndex = 0;
+      var usedVariables = tree.IterateNodesPrefix().OfType<VariableTreeNode>().Select(v => v.VariableName).Distinct();
+      foreach (var variable in dataset.VariableNames) {
+        columnIndex++;
+        if (!usedVariables.Contains(variable)) continue;
+        inputIndex++;
+        variableNameMapping[variable] = GetExcelColumnName(inputIndex);
+      }
     }
 
@@ -137,7 +156,7 @@
         stringBuilder.Append(")");
       } else if (symbol is Logarithm) {
-        stringBuilder.Append("LOG(");
-        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
-        stringBuilder.Append(", EXP(1))"); // Excel does not use the natural logarithm, therefor the base has to be set
+        stringBuilder.Append("LN(");
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
+        stringBuilder.Append(")");
       } else if (symbol is Multiplication) {
         for (int i = 0; i < node.SubtreeCount; i++) {
