// 新規ワークブックの作成 var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.ActiveSheet; // 値を設定 worksheet.Range["B1"].Value = "購入履歴"; worksheet.Range["B2"].Value = "カード番号"; worksheet.Range["C2"].Value = "代理店名"; worksheet.Range["D2"].Value = "カード名義人"; worksheet.Range["E2"].Value = "購入種別"; worksheet.Range["F2"].Value = "金額"; worksheet.Range["G2"].Value = "購入日"; worksheet.Range["B3"].Value = 4008645689741020; worksheet.Range["B4"].Value = 4134470426875510; worksheet.Range["B5"].Value = 4769337626963730; worksheet.Range["B6"].Value = 4929965839844260; worksheet.Range["B7"].Value = 4745932812794040; worksheet.Range["C3"].Value = "H不動産"; worksheet.Range["C4"].Value = "T不動産"; worksheet.Range["C5"].Value = "Z不動産"; worksheet.Range["C6"].Value = "A不動産"; worksheet.Range["C7"].Value = "R不動産"; worksheet.Range["D3"].Value = "伊達"; worksheet.Range["D4"].Value = "上杉"; worksheet.Range["D5"].Value = "最上"; worksheet.Range["D6"].Value = "片倉"; worksheet.Range["D7"].Value = "田村"; worksheet.Range["E3"].Value = "プレミアム購入"; worksheet.Range["E4"].Value = "通常購入"; worksheet.Range["E5"].Value = "プレミアム購入"; worksheet.Range["E6"].Value = "通常購入"; worksheet.Range["E7"].Value = "プレミアム購入"; worksheet.Range["F3"].Value = 17098242; worksheet.Range["F4"].Value = 10269345; worksheet.Range["F5"].Value = 18984670; worksheet.Range["F6"].Value = 8381741; worksheet.Range["F7"].Value = 19093510; worksheet.Range["G3"].Value = new DateTime(2013, 7, 30, 12, 0, 0); worksheet.Range["G4"].Value = new DateTime(2013, 11, 27, 12, 0, 0); worksheet.Range["G5"].Value = new DateTime(2014, 3, 4, 12, 0, 0); worksheet.Range["G6"].Value = new DateTime(2014, 3, 5, 12, 0, 0); worksheet.Range["G7"].Value = new DateTime(2014, 3, 6, 12, 0, 0); // 数値の表示形式を設定 worksheet.Range["B3:B7"].NumberFormat = "0"; worksheet.Range["F3:F7"].NumberFormat = "_(¥* #,##0_);_(¥* (#,##0);_(¥* \"-\"??_);_(@_)"; worksheet.Range["G3:G7"].NumberFormat = "yyyy/m/d h:mm"; // 塗りつぶしを設定 worksheet.Range["B2:G2"].Interior.Color = System.Drawing.Color.FromArgb(231, 230, 230); // 罫線を設定 worksheet.Range["B2:G8"].Borders[BordersIndex.InsideHorizontal].LineStyle = BorderLineStyle.Thin; // 横位置の文字の配置を設定 worksheet.Range["B1"].HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["B2"].HorizontalAlignment = HorizontalAlignment.Right; worksheet.Range["C2:C7"].HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["F2:G2"].HorizontalAlignment = HorizontalAlignment.Right; // フォントスタイルを設定 worksheet.Range["B1:G7"].Font.Name = "IPA P明朝"; worksheet.Range["B1:G2"].Font.Bold = true; worksheet.Range["B1"].Font.Size = 14; worksheet.Range["B2:G2"].Font.Size = 10; worksheet.Range["B3:G7"].Font.Size = 9; // 列幅を設定 worksheet.Range["A:B"].ColumnWidth = 11; worksheet.Range["C:C"].ColumnWidth = 15; worksheet.Range["D:D"].ColumnWidth = 20; worksheet.Range["E:G"].ColumnWidth = 17; // 行高を設定 worksheet.Range["1:1"].RowHeight = 18; // セルを結合 worksheet.Range["B1:G1"].Merge(); // NumbersFitMode を Overflow に設定 workbook.BookView.NumbersFitMode = GrapeCity.Documents.Excel.NumbersFitMode.Overflow; worksheet.PageSetup.IsPercentScale = false; worksheet.PageSetup.FitToPagesWide = 1; worksheet.SheetView.DisplayGridlines = false; // PDF ファイルに保存 workbook.Save("NumbersFitMode.pdf");
' 新規ワークブックの作成 Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.ActiveSheet ' 値を設定 worksheet.Range("B1").Value = "購入履歴" worksheet.Range("B2").Value = "カード番号" worksheet.Range("C2").Value = "代理店名" worksheet.Range("D2").Value = "カード名義人" worksheet.Range("E2").Value = "購入種別" worksheet.Range("F2").Value = "金額" worksheet.Range("G2").Value = "購入日" worksheet.Range("B3").Value = 4008645689741020 worksheet.Range("B4").Value = 4134470426875510 worksheet.Range("B5").Value = 4769337626963730 worksheet.Range("B6").Value = 4929965839844260 worksheet.Range("B7").Value = 4745932812794040 worksheet.Range("C3").Value = "H不動産" worksheet.Range("C4").Value = "T不動産" worksheet.Range("C5").Value = "Z不動産" worksheet.Range("C6").Value = "A不動産" worksheet.Range("C7").Value = "R不動産" worksheet.Range("D3").Value = "伊達" worksheet.Range("D4").Value = "上杉" worksheet.Range("D5").Value = "最上" worksheet.Range("D6").Value = "片倉" worksheet.Range("D7").Value = "田村" worksheet.Range("E3").Value = "プレミアム購入" worksheet.Range("E4").Value = "通常購入" worksheet.Range("E5").Value = "プレミアム購入" worksheet.Range("E6").Value = "通常購入" worksheet.Range("E7").Value = "プレミアム購入" worksheet.Range("F3").Value = 17098242 worksheet.Range("F4").Value = 10269345 worksheet.Range("F5").Value = 18984670 worksheet.Range("F6").Value = 8381741 worksheet.Range("F7").Value = 19093510 worksheet.Range("G3").Value = New DateTime(2013, 7, 30, 12, 0, 0) worksheet.Range("G4").Value = New DateTime(2013, 11, 27, 12, 0, 0) worksheet.Range("G5").Value = New DateTime(2014, 3, 4, 12, 0, 0) worksheet.Range("G6").Value = New DateTime(2014, 3, 5, 12, 0, 0) worksheet.Range("G7").Value = New DateTime(2014, 3, 6, 12, 0, 0) ' 数値の表示形式を設定 worksheet.Range("B3:B7").NumberFormat = "0" worksheet.Range("F3:F7").NumberFormat = "_(¥* #,##0_);_(¥* (#,##0);_(¥* ""-""??_);_(@_)" worksheet.Range("G3:G7").NumberFormat = "yyyy/m/d h:mm" ' 塗りつぶしを設定 worksheet.Range("B2:G2").Interior.Color = System.Drawing.Color.FromArgb(231, 230, 230) ' 罫線を設定 worksheet.Range("B2:G8").Borders(BordersIndex.InsideHorizontal).LineStyle = BorderLineStyle.Thin ' 横位置の文字の配置を設定 worksheet.Range("B1").HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("B2").HorizontalAlignment = HorizontalAlignment.Right worksheet.Range("C2:C7").HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("F2:G2").HorizontalAlignment = HorizontalAlignment.Right ' フォントスタイルを設定 worksheet.Range("B1:G7").Font.Name = "IPA P明朝" worksheet.Range("B1:G2").Font.Bold = True worksheet.Range("B1").Font.Size = 14 worksheet.Range("B2:G2").Font.Size = 10 worksheet.Range("B3:G7").Font.Size = 9 ' 列幅を設定 worksheet.Range("A:B").ColumnWidth = 11 worksheet.Range("C:C").ColumnWidth = 15 worksheet.Range("D:D").ColumnWidth = 20 worksheet.Range("E:G").ColumnWidth = 17 ' 行高を設定 worksheet.Range("1:1").RowHeight = 18 ' セルを結合 worksheet.Range("B1:G1").Merge() ' NumbersFitMode を Overflow に設定 workbook.BookView.NumbersFitMode = GrapeCity.Documents.Excel.NumbersFitMode.Overflow worksheet.PageSetup.IsPercentScale = False worksheet.PageSetup.FitToPagesWide = 1 worksheet.SheetView.DisplayGridlines = False ' PDF ファイルに保存 workbook.Save("NumbersFitMode.pdf")