// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getActiveSheet(); // Set values. worksheet.getRange("B1").setValue("PURCHASE HISTORY"); worksheet.getRange("B2").setValue("CardNumber"); worksheet.getRange("C2").setValue("AgencyName"); worksheet.getRange("D2").setValue("CardHolderFirstName"); worksheet.getRange("E2").setValue("PurchaseType"); worksheet.getRange("F2").setValue("Amount"); worksheet.getRange("G2").setValue("PurchaseDate"); worksheet.getRange("B3").setValue(4008645689741020d); worksheet.getRange("B4").setValue(4134470426875510d); worksheet.getRange("B5").setValue(4769337626963730d); worksheet.getRange("B6").setValue(4929965839844260d); worksheet.getRange("B7").setValue(4745932812794040d); worksheet.getRange("C3").setValue("HALL n HALL"); worksheet.getRange("C4").setValue("TRULIA"); worksheet.getRange("C5").setValue("ZILLOW"); worksheet.getRange("C6").setValue("APARTMENTS"); worksheet.getRange("C7").setValue("REALTOR"); worksheet.getRange("D3").setValue("Mason"); worksheet.getRange("D4").setValue("Prince"); worksheet.getRange("D5").setValue("Evan"); worksheet.getRange("D6").setValue("Lauren"); worksheet.getRange("D7").setValue("Jacob"); worksheet.getRange("E3").setValue("PREMIUM PURCHASE"); worksheet.getRange("E4").setValue("STANDARD PURCHASE"); worksheet.getRange("E5").setValue("PREMIUM PURCHASE"); worksheet.getRange("E6").setValue("STANDARD PURCHASE"); worksheet.getRange("E7").setValue("PREMIUM PURCHASE"); worksheet.getRange("F3").setValue(17098242); worksheet.getRange("F4").setValue(10269345); worksheet.getRange("F5").setValue(18984670); worksheet.getRange("F6").setValue(8381741); worksheet.getRange("F7").setValue(19093510); worksheet.getRange("G3").setValue(new GregorianCalendar(2013, 7, 30, 12, 0, 0)); worksheet.getRange("G4").setValue(new GregorianCalendar(2013, 11, 27, 12, 0, 0)); worksheet.getRange("G5").setValue(new GregorianCalendar(2014, 3, 4, 12, 0, 0)); worksheet.getRange("G6").setValue(new GregorianCalendar(2014, 3, 5, 12, 0, 0)); worksheet.getRange("G7").setValue(new GregorianCalendar(2014, 3, 6, 12, 0, 0)); // Set numberFormat. worksheet.getRange("B3:B7").setNumberFormat("0"); worksheet.getRange("F3:F7").setNumberFormat("_($* #,##0.00_);_($* (#,##0.00);_($* \"-\"??_);_(@_)"); worksheet.getRange("G3:G7").setNumberFormat("m/d/yyyy h:mm"); // Set Fill. worksheet.getRange("B2:G2").getInterior().setColor(Color.FromArgb(231, 230, 230)); // Set borders. worksheet.getRange("B2:G8").getBorders().get(BordersIndex.InsideHorizontal).setLineStyle(BorderLineStyle.Thin); // Set HorizontalAlignment. worksheet.getRange("B1").setHorizontalAlignment(HorizontalAlignment.Center); worksheet.getRange("B2").setHorizontalAlignment(HorizontalAlignment.Right); worksheet.getRange("C2:C7").setHorizontalAlignment(HorizontalAlignment.Center); worksheet.getRange("F2:G2").setHorizontalAlignment(HorizontalAlignment.Right); // Set font style. worksheet.getRange("B1:G7").getFont().setName("Trebuchet MS"); worksheet.getRange("B1:G2").getFont().setBold(true); worksheet.getRange("B1").getFont().setSize(14); worksheet.getRange("B2:G2").getFont().setSize(10); worksheet.getRange("B3:G7").getFont().setSize(9); // Set column width. worksheet.getRange("A:B").setColumnWidth(11); worksheet.getRange("C:C").setColumnWidth(15); worksheet.getRange("D:D").setColumnWidth(20); worksheet.getRange("E:G").setColumnWidth(17); // Set row height worksheet.getRange("1:1").setRowHeight(18); // Set merge. worksheet.getRange("B1:G1").merge(); // Set numbersFitMode is overflow. workbook.getBookView().setNumbersFitMode(com.grapecity.documents.excel.NumbersFitMode.Overflow); worksheet.getPageSetup().setIsPercentScale(false); worksheet.getPageSetup().setFitToPagesWide(1); worksheet.getSheetView().setDisplayGridlines(false); // Save to a pdf file workbook.save("NumbersFitMode.pdf");