Welcome to the WinForms feedback portal. We’re happy you’re here! If you have feedback on how to improve the WinForms, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
The following code creates an index sheet with hyperlinks to all other sheets in a workbook. It works fine up to version 20.1.0.50. In versions 20.1.0.51 and 20.1.0.52 an exception is thrown by
indexSheet.HyperLinks.Add.
public void CreateIndexSheet(string fileName, string sheetName = "Index")
{
var book = GetWorkbook(fileName);
var indexSheet = CreateWorksheet(book, sheetName);
indexSheet.Move(0);
if (indexSheet != null)
{ int row = 1;
foreach (var sheet in book.Worksheets)
{
if (!sheet.Name.Equals(sheetName, StringComparison.InvariantCultureIgnoreCase))
{
IHyperLink hyperlink = indexSheet.HyperLinks.Add(sheet.Range[$"A{row++}"]);
hyperlink.Type = ExcelHyperLinkType.Workbook;
hyperlink.Address = $"'{sheet.Name}'!A1";
hyperlink.TextToDisplay = sheet.Name;
}
}
indexSheet.UsedRange.AutofitColumns();SaveWorkbook(book, fileName); } }