Does something exist in aspose.Cells like "ActiveWorkbook.Names" in VBA Excel

Hello,


I need to list and modify some external link named in an xlsx file.

thanks for all help

Hi,


Thanks for your query.

See the sample code below for your reference:
e.g
Sample code:

Workbook wb = new Workbook(“Book1.xlsx”);
wb.CalculateFormula();

// Create ExternalLinkCollection object to get the all the ext. links in the spreadsheet
ExternalLinkCollection elnks = wb.Worksheets.ExternalLinks;
MessageBox.Show(elnks.Count.ToString());
ExternalLink elnk = elnks[0];
// elnk.AddExternalName(“test”, “=Sheet1!$B$2”);
MessageBox.Show(elnk.DataSource.ToString());

Also, see the document(s) for your reference:


Hope, this helps a bit.

Thank you.

On the excel document we have defined some name refer to external file (for sample Name ‘BGN_1_Balance’ and refersTo =‘C:\WdSites20\RevisionComptable\Exe\Documents\10\DossierPeriodique\2014\FT\10201[BALGEN_N-1.xlsx]BALGEN_N-1’!$H:$J’
And I need now to update the directory . So, I need to know the name of the external link

Hi,


Thanks for providing us further details.

For your case, you may try to use NameCollection and Name object which has Text and RefersTo attributes. See the sample code below for your reference:
e.g
Sample code:

Workbook wb = new Workbook(“e:\test2\Bk_names1.xlsx”);
wb.CalculateFormula();

WorksheetCollection worksheets = wb.Worksheets;
NameCollection names = worksheets.Names;
for (int i = 0; i < names.Count; i++)
{

//Get the name
Console.WriteLine(names[i].Text);
//Get the refers to
Console.WriteLine(names[i].RefersTo);
}

Note: you may also try to use the same Name.Text and Name.RefersTo attributes to set or update the named ranges accordingly.

Let us know if I can be of any further help.

Thank you.

Hi,


Hopefully, your issue is sorted out now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.