Convert Excel Workbook to PDF with image hyperlinks using Aspose.Cells for .NET in C#

Just downloaded Aspose.Cells for evaluation in order to convert Excel workbooks to PDF. I see that it does carry over standard cell hyperlinks. There are images in the workbook that are also hyperlinks (i.e., clicking on an image takes the user to a certain worksheet). Is there an option within Aspose.Cells that will allow these to be carried over into the resulting PDF? Thanks

Hi,


Thanks for providing us details.

Could you provide us the template Excel file (containing image hyperlinks which allows you to navigate to other worksheet(s)), we will check your issue soon.

Thank you.

Thanks for the quick response! After further review I discovered that some images with hyperlinks worked and others didn’t. The ones that did not work were “grouped” together (i.e., select images on Excel worksheet, right click and select “group”). If they are ungrouped then the hyperlinks carried over into PDF. Leaving them grouped is preferred as then they can be moved (via code) as one item instead of each image separately (which is sometime necessary before conversion to PDF).

However, I did notice that where links did not exist (i.e., worksheet not included) the link is displayed when hovered over (see attached image). Is there a way to turn that off? (Conversion via Adobe does not show link on hover over).

Again, thanks!

Hi Chris,

ccastric:
Thanks for the quick response! After further review I discovered that some images with hyperlinks worked and others didn't. The ones that did not work were "grouped" together (i.e., select images on Excel worksheet, right click and select "group"). If they are ungrouped then the hyperlinks carried over into PDF. Leaving them grouped is preferred as then they can be moved (via code) as one item instead of each image separately (which is sometime necessary before conversion to PDF).

Thank you for sharing your analysis. You can avoid the said problem by dynamically un-grouping the shapes before rendering the spreadsheet to PDF format. Please check the code snippet provided at the bottom of this post as well as the attached spreadsheet and its resultant PDF.

ccastric:

However, I did notice that where links did not exist (i.e., worksheet not included) the link is displayed when hovered over (see attached image). Is there a way to turn that off? (Conversion via Adobe does not show link on hover over).

This is Acrobat's behavior to show any external links in the tooltip on mouse hover. Unfortunately, this cannot be controlled with Aspose.Cells APIs.

C#
var book = new Workbook(dir + "hyperlink-grouped.xlsx");
foreach (Worksheet sheet in book.Worksheets)
{
for (int index = 0; index < sheet.Shapes.Count; index++)
{
Shape shape = sheet.Shapes[index];
if (shape.IsGroup)
{
sheet.Shapes.Ungroup((GroupShape)shape);
}
}
}
book.Save(dir + "hyperlink-grouped.pdf", new PdfSaveOptions());