Hi,
Subtotal is an internal function, it shouldn't be exposed. I will see to change it to non public. If you want to do something similar to the "subtotal" menu item in Excel, you can do it manually easily by adding "=Subtotal" formulas, bolding the text, and adding ranges.
I have an example of how to do this in FlexCel.NET and C#, which I will paste below. If this is what you want to do, I can convert it to Delphi code for you, but it isn't difficult since both FlexCels are very similar. Code is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FlexCel.XlsAdapter;
using FlexCel.Core;
namespace ConsoleApplication13
{
class Program
{
static void AddSubTotals(XlsFile xls, int StartRow, int AtChangeInColumn, int AggFunction, int[] SubTotalColumns)
{
object LastVal = xls.GetCellValue(StartRow, AtChangeInColumn);
int LastRow = StartRow;
int row = StartRow + 1;
while (true)
{
object val = xls.GetCellValue(row, AtChangeInColumn);
if (Object.Equals(val, LastVal))
{
row++;
continue;
}
xls.InsertAndCopyRange(new TXlsCellRange(row, 1, row, 1), row, 1, 1, TFlxInsertMode.ShiftRowDown, TRangeCopyMode.None);
for (int stCol = 0; stCol < SubTotalColumns.Length; stCol++)
{
TCellAddress StartCell = new TCellAddress(LastRow, SubTotalColumns[stCol]);
TCellAddress EndCell = new TCellAddress(row - 1, SubTotalColumns[stCol]);
SetCellValueStrong(xls, row, SubTotalColumns[stCol], new TFormula("=Subtotal(" + AggFunction.ToString() + ", " + StartCell.CellRef + ":" + EndCell.CellRef + ")"));
}
SetCellValueStrong(xls, row, AtChangeInColumn, xls.GetStringFromCell(row - 1, AtChangeInColumn) + " Total");
xls.SetRowOutlineLevel(LastRow, row - 1, 2);
row++;
LastRow = row;
LastVal = val;
if (val == null) break;
}
if (row > StartRow)
{
SetCellValueStrong(xls, row, AtChangeInColumn, "Grand Total");
for (int stCol = 0; stCol < SubTotalColumns.Length; stCol++)
{
TCellAddress StartCell = new TCellAddress(StartRow, SubTotalColumns[stCol]);
TCellAddress EndCell = new TCellAddress(row - 1, SubTotalColumns[stCol]);
SetCellValueStrong(xls, row, SubTotalColumns[stCol], new TFormula("=Subtotal(" + AggFunction.ToString() + ", " + StartCell.CellRef + ":" + EndCell.CellRef + ")"));
}
for (int r = StartRow; r < row; r++)
{
if (xls.GetRowOutlineLevel(r) < 1) xls.SetRowOutlineLevel(r, 1);
}
}
}
private static void SetCellValueStrong(XlsFile xls, int row, int col, object value)
{
TFlxFormat fmt = xls.GetFormat(xls.GetCellFormat(row, col));
fmt.Font.Style |= TFlxFontStyles.Bold;
xls.SetCellValue(row, col, value, xls.AddFormat(fmt));
}
static void Main(string[] args)
{
XlsFile xls = new XlsFile(@"r:\st.xlsx", true);
AddSubTotals(xls, 1, 1, 9, new int[] {2});
xls.Save(@"r:\st1.xlsx");
}
}
}