// 新規ワークブックの作成 var workbook = new GrapeCity.Documents.Excel.Workbook(); object[,] data = new object[,]{ {"Name", "City", "Birthday", "Eye color", "Weight", "Height"}, {"Richard", "New York", new DateTime(1968, 6, 8), "Blue", "67", "165"}, {"Damon", "Washington", new DateTime(1986, 2, 2), "Hazel", "76", "176"}, {"Angela", "Washington", new DateTime(1993, 2, 15), "Brown", "68", "145"} }; // A2:F5のエラーは無視しない IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A:F"].ColumnWidth = 15; worksheet.Range["A1:F1"].Merge(); worksheet.Range["A1:F1"].Value = "Range errors not ignored"; worksheet.Range["A1:F1"].Font.Bold = true; worksheet.Range["A1:F1"].HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["A2:F5"].Value = data; worksheet.Tables.Add(worksheet.Range["A2:F5"], true); // A8:F11のエラーを無視する worksheet.Range["A7:F7"].Merge(); worksheet.Range["A7:F7"].Value = "Range errors ignored"; worksheet.Range["A7:F7"].Font.Bold = true; worksheet.Range["A7:F7"].HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["A8:F11"].Value = data; worksheet.Tables.Add(worksheet.Range["A8:F11"], true); worksheet.Range["A8:F11"].IgnoredError = IgnoredErrorType.All; // xlsx ファイルに保存 workbook.Save("IgnoreRangeError.xlsx");
' 新規ワークブックの作成 Dim workbook As New Workbook Dim data(,) As Object = { {"Name", "City", "Birthday", "Eye color", "Weight", "Height"}, {"Richard", "New York", New DateTime(1968, 6, 8), "Blue", "67", "165"}, {"Damon", "Washington", New DateTime(1986, 2, 2), "Hazel", "76", "176"}, {"Angela", "Washington", New DateTime(1993, 2, 15), "Brown", "68", "145"} } ' A2:F5のエラーは無視しない Dim worksheet As IWorksheet = workbook.Worksheets(0) worksheet.Range("A:F").ColumnWidth = 15 worksheet.Range("A1:F1").Merge() worksheet.Range("A1:F1").Value = "Range errors not ignored" worksheet.Range("A1:F1").Font.Bold = True worksheet.Range("A1:F1").HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("A2:F5").Value = data worksheet.Tables.Add(worksheet.Range("A2:F5"), True) ' A8:F11のエラーを無視する worksheet.Range("A7:F7").Merge() worksheet.Range("A7:F7").Value = "Range errors ignored" worksheet.Range("A7:F7").Font.Bold = True worksheet.Range("A7:F7").HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("A8:F11").Value = data worksheet.Tables.Add(worksheet.Range("A8:F11"), True) worksheet.Range("A8:F11").IgnoredError = IgnoredErrorType.All ' xlsx ファイルに保存 workbook.Save("IgnoreRangeError.xlsx")