Create PdfBookmarkEntry for Chart Sheet

Possible Usage Scenarios

Earlier, Aspose.Cells would create PdfBookmarkEntry for a normal sheet. But now Aspose.Cells can also create PdfBookmarkEntry for chart sheet. Since chart sheet does not have any other cell except cell A1, so it will create PdfBookmarkEntry for cell A1 only.

Create PdfBookmarkEntry for Chart Sheet

The following sample code loads the sample Excel file which has four sheets. Two of them are normal sheets and the other two are chart sheets. It creates four bookmark entries as follows

  • Bookmark-I
  • Bookmark-II-Chart1
  • Bookmark-III
  • Bookmark-IV-Chart2

The following screenshot shows the output PDF generated by the sample code for a reference.

todo:image_alt_text

Sample Code

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load sample Excel file
Workbook wb = new Workbook("sampleCreatePdfBookmarkEntryForChartSheet.xlsx");
//Access all four worksheets
Worksheet sheet1 = wb.Worksheets[0];
Worksheet sheet2 = wb.Worksheets[1];
Worksheet sheet3 = wb.Worksheets[2];
Worksheet sheet4 = wb.Worksheets[3];
//Create Pdf Bookmark Entry for Sheet1
PdfBookmarkEntry ent1 = new PdfBookmarkEntry();
ent1.Destination = sheet1.Cells["A1"];
ent1.Text = "Bookmark-I";
//Create Pdf Bookmark Entry for Sheet2 - Chart
PdfBookmarkEntry ent2 = new PdfBookmarkEntry();
ent2.Destination = sheet2.Cells["A1"];
ent2.Text = "Bookmark-II-Chart1";
//Create Pdf Bookmark Entry for Sheet3
PdfBookmarkEntry ent3 = new PdfBookmarkEntry();
ent3.Destination = sheet3.Cells["A1"];
ent3.Text = "Bookmark-III";
//Create Pdf Bookmark Entry for Sheet4 - Chart
PdfBookmarkEntry ent4 = new PdfBookmarkEntry();
ent4.Destination = sheet4.Cells["A1"];
ent4.Text = "Bookmark-IV-Chart2";
//Arrange all Bookmark Entries
ArrayList lst = new ArrayList();
ent1.SubEntry = lst;
lst.Add(ent2);
lst.Add(ent3);
lst.Add(ent4);
//Create Pdf Save Options with Bookmark Entries
PdfSaveOptions opts = new PdfSaveOptions();
opts.Bookmark = ent1;
//Save the output Pdf
wb.Save("outputCreatePdfBookmarkEntryForChartSheet.pdf", opts);