Addig hyperlinks to Column 3 in Excel export

Hi,

i have required to add hyperlink to a column data which is retrieved from database using C#. can you tell me please how to add Hyperlinks to data of specific columns that is retrieved from the database.

when we click that link it should go to the respective link like how we get in MicrosoftWord.

Please help as soon as possible. i have been attaching an example sheet. in that i need to put Hyperlink to URL Column to go to that respective site...


This message was posted using Page2Forum (attachment)
Hi,

Thanks for considering Aspose.

Yes, you can do it quite easily using Aspose.Cells APIs.

May the following code help you for your need:

Workbook workbook = new Workbook();
// Open the template file.
workbook.Open("d:\\test\\WeeklyTask.xls");
// Get the first worksheet in the workbook.
Worksheet worksheet = workbook.Worksheets[0];
// Eliminate the existing text in the cell.
worksheet.Cells["A122"].PutValue(null);
// Add hyperlinks to Cells D2:D15.
int index;
for (int i = 1; i<=worksheet.Cells.MaxDataRowInColumn(3); i++)
{
index = worksheet.Hyperlinks.Add(i,3,1,1,worksheet.Cells[i,3].StringValue);
Aspose.Cells.Hyperlink hlink = worksheet.Hyperlinks[index];
hlink.ScreenTip = "Click to go to respective site";
worksheet.Cells[i,3].Style.Font.Color= Color.Blue;


}
worksheet.AutoFitColumns();
// Save the Excel file
workbook.Save(@"d:\test\addhyperlinks.xls",FileFormatType.Default);

For further reference, please check:

Thank you.