// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getActiveSheet(); worksheet.getRange("A1").setValue("Sales Data"); worksheet.getRange("A2:F6").setValue(new Object[][] { {"Salesperson", "Jan", "Feb", "Mar", "Apr", "May"}, {"Courtney Graves", 76000, 68250, 72000, 99750, 45500}, {"Crystal Cross", 118750, 89250, 121250, 92500, 60750}, {"Jodi Hall", 75500, 56500, 65500, 62750, 77500}, {"Andrew James", 76750, 108500, 88000, 55750, 106000} }); worksheet.getRange("G2").setValue("SparkLine"); worksheet.getRange("G3:G6").setFormula("=COLUMNSPARKLINE(B3:F3,1,,,\"{showMarkers:TRUE}\")"); worksheet.getRange("A1:G1").merge(); worksheet.getRange("A1").getInterior().setColor(Color.GetPurple()); worksheet.getRange("A1").getFont().setColor(Color.GetWhite()); worksheet.getRange("A1").setHorizontalAlignment(HorizontalAlignment.Center); worksheet.getRange("A1:G6").getBorders().setLineStyle(BorderLineStyle.Thin); worksheet.getRange("B3:F6").setNumberFormat("$#,##0"); worksheet.getRange("A1:G2").getFont().setBold(true); worksheet.getRange("A1").getFont().setSize(15); worksheet.getRange("A2:G6").getFont().setSize(13); worksheet.getRange("A:F").autoFit(); worksheet.getRange("1:6").setRowHeight(25); worksheet.getRange("G1").setColumnWidth(30); worksheet.getPageSetup().setOrientation(PageOrientation.Landscape); // Save to a pdf file workbook.save("ColumnSparkline.pdf");