diff --git a/.vscode/launch.json b/.vscode/launch.json
index fac8a7668..11fcb32f0 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -104,7 +104,7 @@
"request": "launch",
"program": "C:/Program Files/Microsoft Office/Office14/EXCEL.EXE",
"args": [
- "${workspaceRoot}/build/Debug/bin/net471/spark_excel-addin64-packed.xll"
+ "${workspaceRoot}/build/Debug/bin/net471/spark_excel-addin64.xll"
],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
diff --git a/src/client/spark_excel/algogen/CellRef.cs b/src/client/spark_excel/algogen/CellRef.cs
index 268b4cf3f..a5cac08ad 100644
--- a/src/client/spark_excel/algogen/CellRef.cs
+++ b/src/client/spark_excel/algogen/CellRef.cs
@@ -216,9 +216,20 @@ namespace bts.excel
/// Unique key
public override string ToString()
{
- return $"'{SheetName}'!{LocalAddress}";
+ if(!string.IsNullOrEmpty(SheetName))
+ return $"'{SheetName}'!{LocalAddress}";
+ else
+ return $"{LocalAddress}";
}
+ public string to_name()
+ {
+ if (!string.IsNullOrEmpty(SheetName))
+ return $"{SheetName}_{LocalAddress}".ToLowerInvariant();
+ else
+ return $"{LocalAddress}".ToLowerInvariant();
+ }
+
public override int GetHashCode()
{
return ToString().GetHashCode();
diff --git a/src/client/spark_excel/algogen/Generate.cs b/src/client/spark_excel/algogen/Generate.cs
index 6ee0d38bc..e0de6435b 100644
--- a/src/client/spark_excel/algogen/Generate.cs
+++ b/src/client/spark_excel/algogen/Generate.cs
@@ -4,7 +4,6 @@ using ExcelDna.Integration;
using spark_excel.grammar;
using Antlr4.Runtime;
-using Antlr4.Runtime.Tree;
namespace bts.excel
{
@@ -37,13 +36,13 @@ namespace bts.excel
public class Generate
{
[ExcelFunction(IsMacroType = true)]
- static public string bts_generate_code_from_sink(string name, [ExcelArgument(AllowReference=true)] object sink)
+ static public string bts_generate_code_from_sink([ExcelArgument(AllowReference=true)] object sink)
{
ExcelReference rref = (ExcelReference)sink;
var formula = XlCall.Excel(XlCall.xlfGetCell, 41, rref);
string sheetname = (string)XlCall.Excel(XlCall.xlSheetNm, rref);
- //var formabs = XlCall.Excel(XlCall.xlfFormulaConvert, form, ExcelDna.
+ var sheetid = rref.SheetId;
var antlrstream = new AntlrInputStream(formula.ToString());
var lexer = new ExcelFormulaLexer(antlrstream);
@@ -59,10 +58,13 @@ namespace bts.excel
throw new ExcelFormulaException(error_listener.ErrorLocation, error_listener.ErrorMessage);
//AbstractParseTreeVisitor
- PreGeneratorVisitor visitor = new PreGeneratorVisitor(rref, sheetname);
+ GeneratorVisitor visitor = new GeneratorVisitor(rref, sheetname, false);
object val = visitor.VisitMain(parsetree);
- return val.ToString();
+ string ret = string.Empty;
+ visitor.get_defs().ForEach(x => ret += x + Environment.NewLine);
+ ret += val.ToString();
+ return ret;
}
}
}
\ No newline at end of file
diff --git a/src/client/spark_excel/algogen/GeneratorVisitor.cs b/src/client/spark_excel/algogen/GeneratorVisitor.cs
index 866025537..0a544c4e5 100644
--- a/src/client/spark_excel/algogen/GeneratorVisitor.cs
+++ b/src/client/spark_excel/algogen/GeneratorVisitor.cs
@@ -1,91 +1,104 @@
using System;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
+using System.Collections.Concurrent;
+using System.Linq;
using spark_excel.grammar;
+using Antlr4.Runtime;
using ExcelDna.Integration;
-using Excel = Microsoft.Office.Interop.Excel;
namespace bts.excel
{
- internal class PreGeneratorVisitor : ExcelFormulaBaseVisitor