I'm creating an Excel report using GemBox.Spreadsheet, but having trouble getting multiple hyperlinks to appear in the same cell. Below is the code:
cell = sheet.Range[rowId, colId++];
foreach (var doc in item.Documents)
{
var h = sheet.HyperLinks.Add(cell);
h.Type = ExcelHyperLinkType.Url;
h.Address = doc.Url.Contains("://") ? doc.Url : @"http://" + doc.Url;
h.TextToDisplay = doc.UrlWords;
}
When I look at the results, only the last link appears.
That is not possible to accomplish in Excel files. Internally, Excel files store hyperlinks outside the cell and they will only contain a reference to an associated cell.
Also, another way that hyperlinks can be defined is with HYPERLINK formula, but even with that approach you cannot achieve your requirement.
Just as a side not, are you sure that you're using GemBox.Spreadsheet?
The ExcelCell.Hyperlink
property does not have Add
method. See the Excel cell hyperlinks example.