// 新規ワークブックの作成 var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet1 = workbook.Worksheets[0]; IWorksheet worksheet2 = workbook.Worksheets.Add(); var data = new object[,] { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; worksheet1.Range["A1:C3"].Value = data; worksheet2.Range["A1:C3"].Value = data; // 行の挿入 worksheet1.Range["A2:B2"].EntireRow.Insert(); worksheet1.Range["3:5"].Insert(); // 列の挿入 worksheet1.Range["B3:B5"].EntireColumn.Insert(); worksheet1.Range["A:A"].Insert(); // 行の削除 worksheet2.Range["A3:A5"].EntireRow.Delete(); worksheet2.Range["2:4"].Delete(); // 列の削除 worksheet2.Range["B3:B5"].EntireColumn.Delete(); worksheet2.Range["A:A"].Delete(); // xlsx ファイルに保存 workbook.Save("InsertDeleteRowsColumns.xlsx");
' 新規ワークブックの作成 Dim workbook As New Workbook Dim worksheet1 As IWorksheet = workbook.Worksheets(0) Dim worksheet2 As IWorksheet = workbook.Worksheets.Add() Dim data = New Object(,) { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} } worksheet1.Range("A1:C3").Value = data worksheet2.Range("A1:C3").Value = data ' 行の挿入 worksheet1.Range("A2:B2").EntireRow.Insert() worksheet1.Range("3:5").Insert() ' 列の挿入 worksheet1.Range("B3:B5").EntireColumn.Insert() worksheet1.Range("A:A").Insert() ' 行の削除 worksheet2.Range("A3:A5").EntireRow.Delete() worksheet2.Range("2:4").Delete() ' 列の削除 worksheet2.Range("B3:B5").EntireColumn.Delete() worksheet2.Range("A:A").Delete() ' xlsx ファイルに保存 workbook.Save("InsertDeleteRowsColumns.xlsx")