// 新規ワークブックの作成 var workbook = new GrapeCity.Documents.Excel.Workbook(); // ワークシートのレイアウトとデータを設定 IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A:A"].ColumnWidth = 2; worksheet.Range["B:B"].ColumnWidth = 10; worksheet.Range["C:C"].ColumnWidth = 15; worksheet.Range["D:G"].ColumnWidth = 20; worksheet.Range["4:14"].RowHeight = 60; worksheet.Range["B3"].Value = "種類"; worksheet.Range["C3"].Value = "データ"; worksheet.Range["B2"].Value = "バーコード"; worksheet.Range["B2:G2"].Merge(true); worksheet.Range["D3:G3"].Value = new object[,]{ {"デフォルト", "色を変更", "ラベルを非表示", "ラベル位置を変更"} }; worksheet.Range["B4:C14"].HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["B4:C14"].VerticalAlignment = VerticalAlignment.Center; worksheet.Range["B2:G3"].HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["B2:G3"].VerticalAlignment = VerticalAlignment.Center; worksheet.Range["B4:C14"].Value = new object[,] { {"QRコード", "Policy:411"}, {"DataMatrix", "Policy:411"}, {"PDF417", "6935205311092"}, {"EAN-8", "4137962"}, {"EAN-13", "6920312296219"}, {"Code39", "3934712708295"}, {"Code93", "6945091701532"}, {"Code49", "6901668002433"}, {"Code128", "465465145645"}, {"Codabar", "9787560044231"}, {"gs1-128", "235465143135"} }; string[] types = { "BC_QRCODE", "BC_DataMatrix", "BC_PDF417", "BC_EAN8", "BC_EAN13", "BC_CODE39", "BC_CODE93", "BC_CODE49", "BC_CODE128", "BC_CODABAR", "BC_GS1_128" }; worksheet.Range["B4:C14"].WrapText = true; worksheet.PageSetup.Orientation = PageOrientation.Landscape; worksheet.PageSetup.PrintGridlines = true; worksheet.PageSetup.PrintTitleRows = "$2:$3"; // 数式を使用し、バーコードを追加 for (var i = 0; i < types.Length; i++) { string columnD = "D" + (i + 4); string columnE = "E" + (i + 4); worksheet.Range[columnD].Formula = "=" + types[i] + "(C" + (i + 4) + ")"; worksheet.Range[columnE].Formula = "=" + types[i] + "(C" + (i + 4) + ",\"#fff\",\"#000\")"; } for (var i = 3; i < types.Length; i++) { string columnF = "F" + (i + 4); string columnG = "G" + (i + 4); worksheet.Range[columnF].Formula = "=" + types[i] + "(C" + (i + 4) + ",,,0)"; worksheet.Range[columnG].Formula = "=" + types[i] + "(C" + (i + 4) + ",,,,\"top\")"; } // PDF ファイルに保存 workbook.Save("AllBarcodes.pdf");
' 新規ワークブックの作成 Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) worksheet.Range("A:A").ColumnWidth = 2 worksheet.Range("B:B").ColumnWidth = 10 worksheet.Range("C:C").ColumnWidth = 15 worksheet.Range("D:G").ColumnWidth = 20 worksheet.Range("4:14").RowHeight = 60 worksheet.Range!B3.Value = "種類" worksheet.Range!C3.Value = "データ" worksheet.Range!B2.Value = "バーコード" worksheet.Range("B2:G2").Merge(True) worksheet.Range("D3:G3").Value = New Object(,) { {"デフォルト", "色を変更", "ラベルを非表示", "ラベル位置を変更"}} worksheet.Range("B4:C14").HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("B4:C14").VerticalAlignment = VerticalAlignment.Center worksheet.Range("B2:G3").HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("B2:G3").VerticalAlignment = VerticalAlignment.Center worksheet.Range("B4:C14").Value = New Object(,) { {"QRコード", "Policy:411"}, {"DataMatrix", "Policy:411"}, {"PDF417", "6935205311092"}, {"EAN-8", "4137962"}, {"EAN-13", "6920312296219"}, {"Code39", "3934712708295"}, {"Code93", "6945091701532"}, {"Code49", "6901668002433"}, {"Code128", "465465145645"}, {"Codabar", "9787560044231"}, {"gs1-128", "235465143135"}} Dim types As String() = {"BC_QRCODE", "BC_DataMatrix", "BC_PDF417", "BC_EAN8", "BC_EAN13", "BC_CODE39", "BC_CODE93", "BC_CODE49", "BC_CODE128", "BC_CODABAR", "BC_GS1_128"} worksheet.Range("B4:C14").WrapText = True worksheet.PageSetup.Orientation = PageOrientation.Landscape worksheet.PageSetup.PrintGridlines = True worksheet.PageSetup.PrintTitleRows = "$2:$3" For i = 0 To types.Length - 1 Dim columnD As String = "D" & (i + 4) Dim columnE As String = "E" & (i + 4) worksheet.Range(columnD).Formula = "=" & types(i) & "(C" & (i + 4) & ")" worksheet.Range(columnE).Formula = "=" & types(i) & "(C" & (i + 4) & ",""#fff"",""#000"")" Next For i = 3 To types.Length - 1 Dim columnF As String = "F" & (i + 4) Dim columnG As String = "G" & (i + 4) worksheet.Range(columnF).Formula = "=" & types(i) & "(C" & (i + 4) & ",,,0)" worksheet.Range(columnG).Formula = "=" & types(i) & "(C" & (i + 4) & ",,,,""top"")" Next ' PDF ファイルに保存 workbook.Save("AllBarcodes.pdf")