Removing hyperlink from a cell also resets the formatting

Tested on 7.6.1

Hello,
Removing a hyperlink from a cell through the code below:

ws.Hyperlinks.RemoveAt(foundIndex);

will reset the formatting on the cell (delete borders, change font color to auto, remove underline etc). The workaround I found is to GetStyle() on the affected cells, then SetStyle() after deleting the hyperlink, but I don’t see why my formatting gets reset when removing a hyperlink.

Thanks!


Hi Bogdan,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue. Removing the hyperlink clears the formatting of the cell. We have tested it with the following code using the source file which is attached with this post. We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-42179.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\book1.xlsx”;


Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.Worksheets[0];


worksheet.Hyperlinks.RemoveAt(0);


workbook.Save(“output.xlsx”);


Hi Bogdan,

Thanks for using Aspose.Cells.

We have looked into your issue further and found that MS-Excel also removes or resets the formatting when you delete the Hyperlink using MS-Excel. So Aspose.Cells behaves same as MS-Excel and it is not a bug.

I see how you want to duplicate the MS-Excel behavior. And since I have found a workaround it’s not such a big issue. For future reference, though, if Aspose.Cells does not follow the Excel behavior, even when Excel does not follow the published standard (I refer to the calcId attribute here), is it considered a bug?

Thanks!

Hi Bogdan,

Thanks for your posting and using Aspose.Cells.

Well, it is MS-Excel behavior and Aspose.Cells follows MS-Excel standards so we cannot go against it. If MS-Excel behaved differently, then we would fix this issue.

Regarding calcId attribute, could you explain your issue further. We will look into it and help you asap.

When MS Excel saves a file in xlsx format, the tag of the workbook.xml file contains a calcId attribute that is usually set to the current version of Excel. Excel uses this attribute to determine whether formulas need to be recalculated or not (it will not recalculate if I’m opening it with the same version of Excel). Aspose.Cells does not set this attribute and sets instead the fullCalcOnLoad attribute to force recalc on load. According to the Open XML standard, this is correct behavior as the calcId attribute is optional. However Excel always sets the calcId and it will set it to “0” in cases when it wants to force a recalc, i.e.

There are third party tools that rely on the Excel behavior of always setting the calcId attribute. It’s not presently an issue for us, as we’re no longer using those tools and obvioulsy those tools do not implement the standard correctly. I just wanted to check if in cases where Excel does not follow the standard, Aspose.Cells is expected to mimic Excel behavior. I also understand that in the case of hyperlinks there is no other standard than Excel’s behavior, so we’re good there :slight_smile:

Thanks!

Hi,

Thanks for your explanation and considering Aspose.Cells.

Aspose.Cells is designed to mimic the Excel behavior, so all the functionalities and features built inside the Aspose.Cells are actually subset of the MS-Excel features. Therefore, it will implement the feature even in cases where MS-Excel does not follow the standard. Thanks for your understanding.