//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.ActiveSheet; // Set values. worksheet.Range["B1"].Value = "PURCHASE HISTORY"; worksheet.Range["B2"].Value = "CardNumber"; worksheet.Range["C2"].Value = "AgencyName"; worksheet.Range["D2"].Value = "CardHolderFirstName"; worksheet.Range["E2"].Value = "PurchaseType"; worksheet.Range["F2"].Value = "Amount"; worksheet.Range["G2"].Value = "PurchaseDate"; 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 = "HALL n HALL"; worksheet.Range["C4"].Value = "TRULIA"; worksheet.Range["C5"].Value = "ZILLOW"; worksheet.Range["C6"].Value = "APARTMENTS"; worksheet.Range["C7"].Value = "REALTOR"; worksheet.Range["D3"].Value = "Mason"; worksheet.Range["D4"].Value = "Prince"; worksheet.Range["D5"].Value = "Evan"; worksheet.Range["D6"].Value = "Lauren"; worksheet.Range["D7"].Value = "Jacob"; worksheet.Range["E3"].Value = "PREMIUM PURCHASE"; worksheet.Range["E4"].Value = "STANDARD PURCHASE"; worksheet.Range["E5"].Value = "PREMIUM PURCHASE"; worksheet.Range["E6"].Value = "STANDARD PURCHASE"; worksheet.Range["E7"].Value = "PREMIUM PURCHASE"; 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); // Set numberFormat. worksheet.Range["B3:B7"].NumberFormat = "0"; worksheet.Range["F3:F7"].NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* \"-\"??_);_(@_)"; worksheet.Range["G3:G7"].NumberFormat = "m/d/yyyy h:mm"; // Set Fill. worksheet.Range["B2:G2"].Interior.Color = System.Drawing.Color.FromArgb(231, 230, 230); // Set borders. worksheet.Range["B2:G8"].Borders[BordersIndex.InsideHorizontal].LineStyle = BorderLineStyle.Thin; // Set HorizontalAlignment. 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; // Set font style. worksheet.Range["B1:G7"].Font.Name = "Trebuchet MS"; 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; // Set column width. worksheet.Range["A:B"].ColumnWidth = 11; worksheet.Range["C:C"].ColumnWidth = 15; worksheet.Range["D:D"].ColumnWidth = 20; worksheet.Range["E:G"].ColumnWidth = 17; // Set row height worksheet.Range["1:1"].RowHeight = 18; // Set merge. worksheet.Range["B1:G1"].Merge(); // Set numbersFitMode is overflow. workbook.BookView.NumbersFitMode = GrapeCity.Documents.Excel.NumbersFitMode.Overflow; worksheet.PageSetup.IsPercentScale = false; worksheet.PageSetup.FitToPagesWide = 1; worksheet.SheetView.DisplayGridlines = false; // Save to a pdf file workbook.Save("NumbersFitMode.pdf");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.ActiveSheet ' Set values. worksheet.Range("B1").Value = "PURCHASE HISTORY" worksheet.Range("B2").Value = "CardNumber" worksheet.Range("C2").Value = "AgencyName" worksheet.Range("D2").Value = "CardHolderFirstName" worksheet.Range("E2").Value = "PurchaseType" worksheet.Range("F2").Value = "Amount" worksheet.Range("G2").Value = "PurchaseDate" 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 = "HALL n HALL" worksheet.Range("C4").Value = "TRULIA" worksheet.Range("C5").Value = "ZILLOW" worksheet.Range("C6").Value = "APARTMENTS" worksheet.Range("C7").Value = "REALTOR" worksheet.Range("D3").Value = "Mason" worksheet.Range("D4").Value = "Prince" worksheet.Range("D5").Value = "Evan" worksheet.Range("D6").Value = "Lauren" worksheet.Range("D7").Value = "Jacob" worksheet.Range("E3").Value = "PREMIUM PURCHASE" worksheet.Range("E4").Value = "STANDARD PURCHASE" worksheet.Range("E5").Value = "PREMIUM PURCHASE" worksheet.Range("E6").Value = "STANDARD PURCHASE" worksheet.Range("E7").Value = "PREMIUM PURCHASE" 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) ' Set numberFormat. worksheet.Range("B3:B7").NumberFormat = "0" worksheet.Range("F3:F7").NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)" worksheet.Range("G3:G7").NumberFormat = "m/d/yyyy h:mm" ' Set Fill. worksheet.Range("B2:G2").Interior.Color = System.Drawing.Color.FromArgb(231, 230, 230) ' Set borders. worksheet.Range("B2:G8").Borders(BordersIndex.InsideHorizontal).LineStyle = BorderLineStyle.Thin ' Set HorizontalAlignment. 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 ' Set font style. worksheet.Range("B1:G7").Font.Name = "Trebuchet MS" 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 ' Set column width. worksheet.Range("A:B").ColumnWidth = 11 worksheet.Range("C:C").ColumnWidth = 15 worksheet.Range("D:D").ColumnWidth = 20 worksheet.Range("E:G").ColumnWidth = 17 ' Set row height worksheet.Range("1:1").RowHeight = 18 ' Set merge. worksheet.Range("B1:G1").Merge() ' Set numbersFitMode is overflow. workbook.BookView.NumbersFitMode = GrapeCity.Documents.Excel.NumbersFitMode.Overflow worksheet.PageSetup.IsPercentScale = False worksheet.PageSetup.FitToPagesWide = 1 worksheet.SheetView.DisplayGridlines = False ' save to a pdf file workbook.Save("NumbersFitMode.pdf")