Convert cell content to hyperlink

I’m importing data into a sheet this way:
worksheet.Cells.ImportDataTable(exportResult, true, “A1”);

One column contains hyperlinks.

How do I convert/replace the content of this column to a hyperlink column (=HYPERLINK(“https:\domain.com”)?

Thanks in advance.

Best regards
Morten

@mortenma

Thanks for using Aspose APIs.

The following sample code explains how to add hyperlink using formula or normally. You will have to write your own algorithm that will make use of one or both of these techniques to fulfill your needs.

Please see the output Excel file generated by the code and screenshot showing the output Excel file for a reference.

Download Link:
Output Excel File.zip (6.2 KB)

C#

//Create workbook
Workbook wb = new Workbook();

//Access first worksheet
Worksheet ws = wb.Worksheets[0];

//Adding hyperlink using formula
string formula = "=HYPERLINK(\"https://www.aspose.com\", \"My Website-1\")";
ws.Cells["B4"].Formula = formula;

//Adding hyperlink in normal way
int idx = ws.Hyperlinks.Add("B9", 1, 1, "https://www.aspose.com");
ws.Hyperlinks[idx].TextToDisplay = "My Website-2";

//Set the width of the column
ws.Cells.SetColumnWidth(1, 20);

//Save the output Excel file
wb.Save("output.xlsx");

Screenshot:

@bcormier

Thanks for considering Aspose APIs.

We have looked into your issue further and decided to add a new property that will fulfill your needs easily. We have added a New Feature request for your issue as follows

  • CELLSNET-45889 - Convert Cell Content to Hyperlink - ImportTableOptions.IsFormulas needed

Once, we will have some fix for you or any other update, we will let you know asap.

@mortenma

Thanks for using Aspose APIs.

This is to inform you that we have fixed your issue CELLSNET-45889 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

thanks for the quick response

@mortenma

Thanks for using Aspose APIs.

Please download and try the following fix and let us know your feedback.

The issues you have found earlier (filed as CELLSNET-45889) have been fixed in this Aspose.Cells for .NET 18.2 update.

Please also check the following article: