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

Free Support Forum - aspose.com

Incorrect external link path for relative external links

We found another bug in the external link paths. Consider the following test files: ExternalLinks.zip (15.9 KB)

This zip contains a file ExternalLinks.xlsx and a file in a subfolder NewFolder\Data.xlsx. We created an external link from the first file to the second file. This is saved in the spreadsheet as a relative external link.

Now consider the following test code:

var workbook = new Workbook(@"C:\Users\Willem-Jan\Desktop\ExternalLinks.xlsx");

var formula1 = workbook.Worksheets["Sheet1"].Cells["A1"].Formula;
// INCORRECT: ='C:/Users/Willem-Jan/Desktop/NewFolder\[Data.xlsx]Sheet1'!$A$2

var formula2 = workbook.Worksheets["Sheet1"].Cells["A2"].Formula;
// INCORRECT: ='C:/Users/Willem-Jan/Desktop/NewFolder\Data.xlsx'!Title

If we load the file using the workbook constructor without path, the external link is resolved correctly:

Directory.SetCurrentDirectory(@"C:\Users\Willem-Jan\Desktop");
            
var workbook = new Workbook(@"ExternalLinks.xlsx");

var formula1 = workbook.Worksheets["Sheet1"].Cells["A1"].Formula;
// CORRECT: ='C:\Users\Willem-Jan\Desktop\NewFolder\[Data.xlsx]Sheet1'!$A$2

var formula2 = workbook.Worksheets["Sheet1"].Cells["A2"].Formula;
// CORRECT: ='C:\Users\Willem-Jan\Desktop\NewFolder\Data.xlsx'!Title

Of course the path with forward slashes and backward slashes is incorrect, we expect the file path with all backward slashes (just like in Excel).

We’re using Aspose.Cells v22.3.0. Can you fix this bug? Thank you!

@perfectxl,

I tested your scenario/case a bit using latest version/fix (Aspose.Cells v22.3.0),it works fine and as expected. I first downloaded your zipped archive and placed your files @ “C:\Users\Tst_User\Downloads” folder. Now I used the following sample code with your file and printed the formulas on console output:
e.g.
Sample code:

var workbook = new Workbook(@"C:\Users\Tst_User\Downloads\ExternalLinks.xlsx");

var formula1 = workbook.Worksheets["Sheet1"].Cells["A1"].Formula;
Console.WriteLine(formula1);

var formula2 = workbook.Worksheets["Sheet1"].Cells["A2"].Formula;
Console.WriteLine(formula2);

output:

=‘C:\Users\Tst_User\Downloads\NewFolder[Data.xlsx]Sheet1’!$A$2
=‘C:\Users\Tst_User\Downloads\NewFolder\Data.xlsx’!Title

I guess the output is ok.

Ah, I just found that this is related to .NET Core.

If I run the code with Aspose.Cells v22.3.0 on .NET Framework I get the following (correct) output:

='C:\Users\Willem-Jan\Downloads\NewFolder\[Data.xlsx]Sheet1'!$A$2
='C:\Users\Willem-Jan\Downloads\NewFolder\Data.xlsx'!Title

If I run the code with Aspose.Cells v22.3.0 on .NET Core I get the following (incorrect) output:

='C:/Users/Willem-Jan/Downloads/NewFolder\[Data.xlsx]Sheet1'!$A$2
='C:/Users/Willem-Jan/Downloads/NewFolder\Data.xlsx'!Title

@perfectxl,

Thanks for providing further details.

We have logged a new ticket with an id “CELLSNETCORE-369” for your issue. The issue is logged as following:
CELLSNETCORE-369 - Incorrect external link path for relative external links

Once we have an update on it, we will let you know.

@perfectxl,

We have fixed this issue. The fix will be included in our (upcoming) regular release Aspose.Cells for .NET v22.4.
Currently, please set Workbook.FileName as temporary solution as the following codes:

var workbook = new Workbook(@"C:\Users\administrator\Desktop\ExternalLinks\ExternalLinks.xlsx");
workbook.FileName = @"C:\Users\administrator\Desktop\ExternalLinks\ExternalLinks.xlsx"