Aplicar subtotal y cambiar dirección de resumen de contorno de filas debajo del detalle

Imágenes de los archivos de origen y salida

La siguiente captura de pantalla muestra el archivo de Excel de origen utilizado en el código de ejemplo a continuación, que contiene algunos datos en las columnas A y B.

todo:image_alt_text

La siguiente captura de pantalla muestra el archivo de Excel de salida generado por el código de ejemplo. Como se puede ver, se ha aplicado un subtotal al rango A2:B11 y la dirección del contorno es resumen de filas debajo del detalle.

todo:image_alt_text

Código C# para aplicar subtotal y cambiar la dirección de las filas de resumen de contorno

Aquí está el código de ejemplo para lograr el resultado mostrado anteriormente.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create workbook from source Excel file
Workbook workbook = new Workbook(dataDir + "Book1.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Get the Cells collection in the first worksheet
Cells cells = worksheet.Cells;
// Create a cellarea i.e.., A2:B11
CellArea ca = CellArea.CreateCellArea("A2", "B11");
// Apply subtotal, the consolidation function is Sum and it will applied to Second column (B) in the list
cells.Subtotal(ca, 0, ConsolidationFunction.Sum, new int[] { 1 }, true, false, true);
// Set the direction of outline summary
worksheet.Outline.SummaryRowBelow = true;
// Save the excel file
workbook.Save(dataDir + "output_out.xlsx");