I'm trying to achieve something, i thought, quite simple: i'm trying to add a row with 5 columns of SUBTOTALs.
Attached is an example of what i'm trying to do.
The bold rows have the SUBTOTAL formula. For example, In the Test 4 bold row i have "SUBTOTAL(9;B7:B8)" for the B col, "SUBTOTAL(9;C7:C8)" for the C col, etc.
My problem is when i try to add the B col SUBTOTAL everything goes well, but when i try to add the C col SUBTOTAL i recieve an "Unexpected token" exception.
This is my code:
- Code: Select all
formula = "SUBTOTAL(9,#COL#7:#COL#8)";
compras.Range[9, 2].Formula = formula.Replace("#COL#", "B");
compras.Range[9, 3].Formula = formula.Replace("#COL#", "C");
compras.Range[9, 4].Formula = formula.Replace("#COL#", "D");
compras.Range[9, 5].Formula = formula.Replace("#COL#", "E");
compras.Range[9, 6].Formula = formula.Replace("#COL#", "F");
compras.Range[9, 7].Formula = formula.Replace("#COL#", "G");
compras.Range[9, 8].Formula = formula.Replace("#COL#", "H");
compras.Range[9, 9].Formula = formula.Replace("#COL#", "I");
Error Message:
Unexpected token.Unexpected token type: Identifier, string value: C7:C8 . Formula: SUBTOTAL(9,C7:C8)
StackTrace of the error:
en ᣛ.ᜀ(String A_0, Exception A_1)
en ᣛ.ᜀ(String A_0)
en ᧕.ᜀ(Priority A_0, Dictionary`2 A_1, Int32 A_2, ParseFormulaOptions A_3, ParseParameters A_4)
en ᧕.ᜀ(ParseFormulaOptions A_0, ParseParameters A_1, ExcelFunction A_2)
en ᧕.ᜀ(ExcelFunction A_0, Dictionary`2 A_1, Int32 A_2, ParseFormulaOptions A_3, ParseParameters A_4)
en ᧕.ᜀ(Dictionary`2 A_0, Int32 A_1, ParseFormulaOptions A_2, ParseParameters A_3)
en ᧕.ᜀ(Priority A_0, Dictionary`2 A_1, Int32 A_2, ParseFormulaOptions& A_3, ParseParameters A_4)
en ᧕.ᜀ(Priority A_0, Dictionary`2 A_1, Int32 A_2, ParseFormulaOptions A_3, ParseParameters A_4)
en ᧕.ᜁ(String A_0, Dictionary`2 A_1, Int32 A_2, ParseFormulaOptions A_3, ParseParameters A_4)
en Spire.Xls.Core.Spreadsheet.FormulaUtil.ᜀ(String A_0, IWorksheet A_1, Dictionary`2 A_2, Int32 A_3, Int32 A_4, Boolean A_5)
en Spire.Xls.Core.Spreadsheet.XlsRange.SetFormula(String value, Dictionary`2 hashWorksheetNames, Boolean bR1C1)
en Spire.Xls.Core.Spreadsheet.XlsRange.SetFormula(String value)
en Spire.Xls.Core.Spreadsheet.XlsRange.OnValueChanged(String old, String value)
en Spire.Xls.Core.Spreadsheet.XlsRange.set_Value(String value)
en Spire.Xls.Core.Spreadsheet.XlsRange.set_Formula(String value)
My Spire.XLS.dll version is 7.0.0.7040