We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose Grouping


I have some data like this:

Col A Col B Col C
AAA Equity 100
AAA Bond 200
AA Equity 50
AA Bond 300

And I would like to present like this:

AAA 300
Equity 100
Bond 200
AA 350
Equity 50
Bond 300

I’ve no idea how to use the grouping and subtotal on one line and the detail below

I have had a look at the documentation and the use of the grouping parameters but I can’t work it out, please help!


You can use MS Excel’s Subtotal feature for grouping data but the output might be slightly different than what you want, but you may live with it or modify the relevant cells manually afterwards. But this is how MS Excel does for Subtotal feature. See the following sample code that you may try with the template file (attached) for your reference:
Sample code:

String filePath = "f:\\files\\Bk_subtotal1.xlsx";
Workbook workbook = new Workbook(filePath);
Worksheet worksheet = workbook.getWorksheets().get(0);
CellArea ca = CellArea.createCellArea("A2", "C5");
worksheet.getCells().subtotal(ca,0,ConsolidationFunction.SUM, new int[] {2}, false, false, false);

Please also find the output file in the zip archive (attached).
files1.zip (13.9 KB)

Hope, this helps a bit.