//create a new workbook Workbook workbook = new Workbook(); IRange targetRange = workbook.getActiveSheet().getRange("A1:C9"); // Set data targetRange.setValue(new Object[][] { {"Player", "Side", "Commander"}, {1, "Soviet", "AI"}, {2, "Soviet", "AI"}, {3, "Soviet", "Human"}, {4, "Allied", "Human"}, {5, "Allied", "Human"}, {6, "Allied", "AI"}, {7, "Empire", "AI"}, {8, "Empire", "AI"} }); // Subtotal targetRange.subtotal(2, // Side ConsolidationFunction.Count, new int[] { 2 } // Side ); targetRange.autoFit(); //save to an excel file workbook.save("AddSubtotal.xlsx");
//create a new workbook var workbook = Workbook() val targetRange = workbook.activeSheet.getRange("A1:C9") // Set data targetRange.setValue(arrayOf(arrayOf("Player", "Side", "Commander"), arrayOf(1, "Soviet", "AI"), arrayOf(2, "Soviet", "AI"), arrayOf(3, "Soviet", "Human"), arrayOf(4, "Allied", "Human"), arrayOf(5, "Allied", "Human"), arrayOf(6, "Allied", "AI"), arrayOf(7, "Empire", "AI"), arrayOf(8, "Empire", "AI"))) // Subtotal targetRange.subtotal(2, // Side ConsolidationFunction.Count, intArrayOf(2) // Side ) targetRange.autoFit() //save to an excel file workbook.save("AddSubtotal.xlsx")