How to know which cells has externalLinks

When I get the ExternalLinks by the code below, how I can I know which worksheet and cell has externallinks.
ExternalLinkCollection links = workbook.Worksheets.ExternalLinks;


I am afraid there is no direct way to get the cells which use specific external links. You may check the link by searching cell’s formula by yourselves. I think you may retrieve using precedents of the cell and try to trace if it has external link or not, see the sample code for your reference.
Sample code:

Cells cells = workbook.Worksheets[0].Cells;
            Aspose.Cells.Cell cell = cells["A1"];
            //Tracing precedents of the cell A1.
            //The return array contains ranges and cells.
            ReferredAreaCollection ret = cell.GetPrecedents();
            //Printing all the precedent cells' name.
            if (ret != null)
                for (int m = 0; m < ret.Count; m++)
                    ReferredArea area = ret[m];
                    StringBuilder stringBuilder = new StringBuilder();
                    if (area.IsExternalLink)
                         //your code goes here    

Hope, this helps a bit.

Thank you, but I got another question, when I use the code ExternalLinkCollection links = workbook.Worksheets.ExternalLinks; to get all the externalLinks, I found I cannot find the links by searching cell’s formula when some of the links are ‘IsReferred = true’ and ‘IsVisible = true’, do you know why?


External links are saved as separate entities in Excel files and does not have any direct attachments to the cells. You have to use your own code (refer to the suggested code segment) to accomplish the task for your requirements.

Thanks, I will try the suggested code. Actually I am a little worried if checking every cell will cause a performance issue when the excel is very big.


If you find significant performance issue for bigger files, kindly do share your sample code (runnable) and template files to show the issue, we will check further.

PS. please zip the files prior attaching.

I think it’s not that bad, I’ve tried a excel with 600000 rows and 11 columns, it takes about one minute to check all the cells. I think it’s acceptable. Really thank you for your supporting.


Yes, it is reasonable.