Could you please provide me a way to calculate sub-totals and Totals.
Suppose I have below records and want to display sub totals and Totals.
1 ALTO-LXI 300
2 ALTO-800 200
Sub-total 500
3 RITZ VXI 219
4 RITZ ZXI 190
sub-total 409
Total 909
Hi Vidya,
Thanks for sharing the article.
Now I have got an idea on how to add sub-totals using Aspose. Actually I have huge data in my report (like 20 columns and 4000+ rows) and want to display sub-totals on few columns which is having amounts, quantity, possitions etc…(around 8 columns)
how to use below statement for multiple columns
cells.Subtotal(ca, 0, ConsolidationFunction.Sum, New Integer() { 1 })
Thanks in advance.
Hi Vidya,
Workbook workbook = new Workbook(“D:/Book1.xlsx”);
var cells = workbook.Worksheets[0].Cells;
//Create a CellArea on which Subtotal has to be applied
//for the sake of demonstration the CellArea is defined
//as B1:D20
CellArea ca = new CellArea();
ca.StartRow = 0;
ca.StartColumn = 1;
ca.EndRow = 19;
ca.EndColumn = 3;
//ConsolidationFunction is Sum
//Subtotal to be applied on columns C & D (1 & 2 from the CellArea)
cells.Subtotal(ca, 0, ConsolidationFunction.Sum, new int[] {1,2});
workbook.Save(“D:/output.xlsx”);
Thanks for posting the respose.
I want to do this for more columns and I am capturing the same in below object
Dim strList()
where as I am getting error when pass this parameter in subtotal method.
xlWs.Cells.Subtotal(ca, intGroupByColIndex, ConsolidationFunction.Sum, totalList:=strList)
Kindly suggest.
Hi Vidya,
I have issues in displaying sutotals in my report.
In my report I have 12 columns,20 rows and need to display subtotals.
sometimes my calculation is ignoring the first row… I used above example for displaying the subtotals.
Thanks in advance.
Hi Vidya,
My code is very simple.
1) Extracting data from Database and keeping in an Excel using aspose.
We used ImportDataTable method to copy the data. I am extracting 12 columns and 20 records.
But at the bottom I am expecting sub-totals in a separate row.
Could you please give me an example of displaying sample data of (8 columns and 3-5 rows) along with the sub-totals so that I will follow in the same way.
Thanks a lot for your support.
Hi Vidya,