[]
        
(Showing Draft Content)

Export Cell Checkboxes

DsExcel Java supports exporting an Excel worksheet that contains cell checkboxes to a PDF document. If a cell that contains a checkbox also has a cell type set, the cell type has a higher display priority than the checkbox. After exporting to PDF, the cell content is displayed according to its cell type.

// Create a new workbook.
Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.getWorksheets().get(0);

// Set data.
worksheet.getRange("B:C").setColumnWidth(28);
worksheet.getRange("B3:C3").getInterior().setColor(Color.FromArgb(155, 194, 230));
worksheet.getRange("B3:C3").getFont().setBold(true);
workbook.getActiveSheet().getRange("B3").setValue("Format");
workbook.getActiveSheet().getRange("C3").setValue("Checkbox State");
workbook.getActiveSheet().getRange("B4").setValue("Without Format");
workbook.getActiveSheet().getRange("B5").setValue("With Format");

// Add checkboxes to cells in the C4:C5 range.
workbook.getActiveSheet().getRange("C4:C5").setValue(true);
worksheet.getRange("C4:C5").setCellType(new CheckBoxCellType());

// Set formatting for cell C5.worksheet.
getRange("C5").getInterior().setColor(Color.GetOrange());
worksheet.getRange("C5").getFont().setColor(Color.GetRed());
worksheet.getRange("C5").getFont().setSize(16);
worksheet.getRange("C5").setHorizontalAlignment(HorizontalAlignment.Left);

// Save to an excel file.
workbook.save("CellCheckboxtoPDF.pdf");

The output is shown in the figure below:

image