Unable to add the Hyperlink programmetically in ExcelCell using OfficeOpenXml


  • We are working on web-app where we need to modify the existing Excel file. We are using 'OfficeOpenXml' to modify the file.

    Everything is working fine except Hyperlink, we are unable to add the hyper link programetically. Below is the code we used:

    using OfficeOpenXml;

    ExcelPackage xlPackage = new ExcelPackage(newFile);

    worksheet = xlpackage.Workbook.Worksheets["WorkSheetName"];

    worksheet.Cell(3, 4).Hyperlink = hyperlink; -(hyperlink System.Uri)

    This code doesn't give any compile/runtime error but when we try to open the Excel file then the related Worksheet got corrupted.

    Are there any ways to add Hyperlink programettically using C# to an Excel Cell in an existing Excel file?


    Wednesday, March 19, 2014 8:19 AM

All replies

  • Hi,

    Based on your code, I find you are using an open-source software ExcelPackage to interact to a spreadsheet with Office Open XML format instead of using Open XML SDK.

    For more questions about ExcelPackage, I suggest you posting in ExcelPackage Discussion forum for more effective responses.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 20, 2014 5:23 AM
  • You could choose to use Open XML SDK.

    Here is a KB my help you:

    How to Insert a Hyperlink in Excel using Open XML SDK 2.0

    Thursday, March 20, 2014 5:33 AM