DeleteColumns & Hyperlink

I added hyperlinks code like below,

var name = workbook.Worksheets[iSheet].Cells[l, m].Name;
workbook.Worksheets[iSheet].Hyperlinks.Add(7, m, 1, 1, name);

eg. hyperlink point to H165, when I deletecolumns() code like,
cells.DeleteColumns(0, 5, true);

Click the hyperlink, still jump to H165. I’d like it jump to C165


any solution?

Hi,

Thanks for your posting. Please download and use the latest version:
Aspose.Cells
for .NET v7.2.0.2

and let us know your feedback.

If the problem still occurs, then please provide me your complete sample runnable code/project, which we could run and check the issue.

I got the latest verions, still not what I need. please help.

code to add hyperlink,
Sheet1.Hyperlinks.Add(4, 2, 3, 1, “‘Sheet1’!C10”);

see the attachement,

I wanna click ClickMe , jump to C10, the background is yellow cell.

if I run code
Sheet1.Cells.DeleteColumn(0, true);

click ClickMe still jump to C10, I wanna it jump to B10, the background is yellow cell.

Hi,

It is an Ms-Excel behavoior. You can experiment it in Ms-Excel 2010 by deleting the column A and then clicking again your link, it will take you to C10 instead of B10.

So, it is not a bug.

yes, if we set the hyperlink to a cell name such as C10, it will jump cell C10. are there any way not to set name to a hyperlink? eg. set row index and column index? even I delete one column, still jump to that cell

Hi,

I think, that is not possible.

But you can change/update it programmatically using the following code.


worksheet.Hyperlinks[0].Address=“Sheet1!B10”;

Hi,

After looking into further, I found it is possible.

Please try the following code. I have attached the output.xls file.

The code names cell F16 as MyCell then it creates a Hyperlink that is linked to cell MyCell. Now even if you delete the column A, it will not make the link invalid, it will still jump to MyCell.

C#


Workbook workbook = new Workbook();


Worksheet worksheet = workbook.Worksheets[0];


Range rng = worksheet.Cells.CreateRange(“F16”);


rng.Name = “MyCell”;


var o = worksheet.Hyperlinks.Add(“D15”, 1, 1, “MyCell”);


workbook.Save(“output.xls”);

ok, thanks.

our code is complex, lots of hyperlinks, some link to different sheets, and delete rows or columns frequently. I think it is not easy to reset the hyperlink. I will try to find other solution.