// 新規ワークブックの作成 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"].Insert();//Auto worksheet1.Range["B2"].Insert(InsertShiftDirection.Down); worksheet1.Range["C2"].Insert(InsertShiftDirection.Right); // セルの削除 worksheet2.Range["A2"].Delete();//Auto worksheet2.Range["B2"].Delete(DeleteShiftDirection.Left); worksheet2.Range["C2"].Delete(DeleteShiftDirection.Up); // xlsx ファイルに保存 workbook.Save("InsertCellsDeleteCells.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.Insert() 'Auto worksheet1.Range!B2.Insert(InsertShiftDirection.Down) worksheet1.Range!C2.Insert(InsertShiftDirection.Right) ' セルの削除 worksheet2.Range!A2.Delete() 'Auto worksheet2.Range!B2.Delete(DeleteShiftDirection.Left) worksheet2.Range!C2.Delete(DeleteShiftDirection.Up) ' xlsx ファイルに保存 workbook.Save("InsertCellsDeleteCells.xlsx")