Excel API Library for Java - Sample Browser | Document Solutions | Insert or delete table rows and columns

[フレーム] src="bundle.js"> This sample demonstrates how to add and delete columns and rows in a table. // Create a new workbook Workbook workbook = new Workbook(); Object data = new Object[][]{ {"Name", "City", "Birthday", "Eye color", "Weight", "Height"}, {"Richard", "New York", new GregorianCalendar(1968, 5, 8), "Blue", 67, 165}, {"Nia", "New York", new GregorianCalendar(1972, 6, 3), "Brown", 62, 134}, {"Jared", "New York", new GregorianCalendar(1964, 2, 2), "Hazel", 72, 180}, {"Natalie", "Washington", new GregorianCalendar(1972, 7, 8), "Blue", 66, 163}, {"Damon", "Washington", new GregorianCalendar(1986, 1, 2), "Hazel", 76, 176}, {"Angela", "Washington", new GregorianCalendar(1993, 1, 15), "Brown", 68, 145} }; IWorksheet worksheet = workbook.getWorksheets().get(0); worksheet.getRange("A1:F7").setValue(data); worksheet.getRange("A:F").setColumnWidth(15); // add table. ITable table = worksheet.getTables().add(worksheet.getRange("A1:F7"), true); // add table column before first column. table.getColumns().add(0); // add table column before second column. table.getColumns().add(1); // delete first table column. table.getColumns().get(0).delete(); // delete "City" table column. table.getColumns().get("City").delete(); // insert a table row in table's last row. table.getRows().add(); // delete second table row. table.getRows().get(1).delete(); // Save to an excel file workbook.save("InsertDeleteTableRowColumns.xlsx"); // Create a new workbook var workbook = Workbook() val data = arrayOf(arrayOf("Name", "City", "Birthday", "Eye color", "Weight", "Height"), arrayOf("Richard", "New York", GregorianCalendar(1968, 5, 8), "Blue", 67, 165), arrayOf("Nia", "New York", GregorianCalendar(1972, 6, 3), "Brown", 62, 134), arrayOf("Jared", "New York", GregorianCalendar(1964, 2, 2), "Hazel", 72, 180), arrayOf("Natalie", "Washington", GregorianCalendar(1972, 7, 8), "Blue", 66, 163), arrayOf("Damon", "Washington", GregorianCalendar(1986, 1, 2), "Hazel", 76, 176), arrayOf("Angela", "Washington", GregorianCalendar(1993, 1, 15), "Brown", 68, 145)) val worksheet = workbook.worksheets.get(0) worksheet.getRange("A1:F7").value = data worksheet.getRange("A:F").columnWidth = 15.0 // add table. val table = worksheet.tables.add(worksheet.getRange("A1:F7"), true) // add table column before first column. table.columns.add(0) // add table column before second column. table.columns.add(1) // delete first table column. table.columns.get(0).delete() // delete "City" table column. table.columns.get("City").delete() // insert a table row in table's last row. table.rows.add() // delete second table row. table.rows.get(1).delete() // Save to an excel file workbook.save("InsertDeleteTableRowColumns.xlsx")

AltStyle によって変換されたページ (->オリジナル) /