We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding hyperlinks with LightCellsDataProvider in .NET

Hi, I’m trying to add hyperlinks to an OOXML workbook created with LightCellsDataProvider in v7.0.4.
If I’m adding a hyperlink in a StartCell, just nothing happens. If I’m adding a hyperlink in a StartSheet callback, the cell gets formatted like a hyperlink, but no link is actually added either.

Is there a way to add a hyperlink when creating an OOXML workbook with LightCellsDataProvider?


Please give us a sample (complete runnable code) console application with v7.1.0.1 (latest version/fix) to reproduce the issue on our end, you may zip the application prior attaching here. We will check it soon.

Thank you.


I’m attaching a sample project where I’m trying to generate an ooxml workbook with hyperlinks via LightCellsDataProvider.


Thanks for the sample project.

I can notice the issue as you have mentioned by your provided project. The generated XLS format is just fine regarding hyperlinks but XLSX is not fine. We will look into the issue soon. I have logged a ticket with an id: CELLSNET-40311.

Thank you.


When saving XLSX file, we save hyperlinks first, and then save cells data (call methods in LightCellsDataProvider).

For your code, before calling the implementation of LightCellsDataProvider, no hyperlink be created so no hyperlink be saved to the resultant file. So, for all other objects except cells style and content, such as merged areas, shapes, hyperlinks and so on, they should be created correctly before Workbook.Save() method.

In the implementation of LightCellsDataProvider, only cell content and style can be set/modified. So please change your code like:


workbook.Worksheets[0].Hyperlinks.Add(“A1”, 1, 1, “http:[//microsoft.com](https://microsoft.com/)”);

//Links won’t work for OOXML only. If I used XlsSaveOptions instead, they’d be added just fine.

var ooxmlSaveOptions = new OoxmlSaveOptions();

ooxmlSaveOptions.LightCellsDataProvider = new TestDataProvider(workbook);

workbook.Save(…, ooxmlSaveOptions);

And remove the code of adding hyperlinks from TestDataProvider.

The fact that your code works for XLS file is because when saving XLS file we save cells data(call methods in implementation of LightCellsDataProvider) before saving hyperlinks currently. However, there is no guarantee for such order in the version evolution of aspose.cells and we may change the order to be same with saving xlsx files in later versions.