[]
DsExcel .NET 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.
var workbook = new GrapeCity.Documents.Excel.Workbook();
IWorksheet worksheet = workbook.Worksheets[0];
// Set data.
worksheet.Range["B:C"].ColumnWidth = 28;
worksheet.Range["B3:C3"].Interior.Color = Color.FromArgb(155, 194, 230);
worksheet.Range["B3:C3"].Font.Bold = true;
workbook.ActiveSheet.Range["B3"].Value = "Format";
workbook.ActiveSheet.Range["C3"].Value = "Checkbox State";
workbook.ActiveSheet.Range["B4"].Value = "Without Format";
workbook.ActiveSheet.Range["B5"].Value = "With Format";
// Add checkboxes to cells in the C4:C5 range.
workbook.ActiveSheet.Range["C4:C5"].Value = true;
worksheet.Range["C4:C5"].CellControl.SetCheckbox();
// Set formatting for cell C5.
worksheet.Range["C5"].Interior.Color = Color.Orange;
worksheet.Range["C5"].Font.Color = Color.Red;
worksheet.Range["C5"].Font.Size = 16;
worksheet.Range["C5"].HorizontalAlignment = HorizontalAlignment.Left;
// Save to an excel file.
workbook.Save("CellCheckboxtoPDF.pdf");The output is shown in the figure below:
