Free Support Forum - aspose.com

Change of document absolute path

Hi Aspose team,

If I open workbook.xml file in structure I can find something like:

<mc:AlternateContent xmlns:mc=“http://schemas.openxmlformats.org/markup-compatibility/2006”>
<mc:Choice Requires=“x15”>
<x15ac:absPath xmlns:x15ac=“http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac” url=“X:\GROUP-FINANCE\ABC\FORECASTS\FY 2009\2009-03 March Test”/>
</mc:Choice>
</mc:AlternateContent>

Is there any option to change this absolute path (absPath) of document through Aspose.Cells?

Thanks,
Oliver

@dr.doc,
You may please try the following sample code using the latest version Aspose.Cells for .NET 21.3.

// Load your source excel file containing the external link
Workbook wb = new Workbook("sample.xlsx");

// Access the first external link
ExternalLink externalLink = wb.Worksheets.ExternalLinks[0];

// Print the data source of external link, it will print existing remote
// path
Console.WriteLine("External Link Data Source: " + externalLink.DataSource);

// Remove the remote path and print the new data source
// Assign the new data source to external link and print again, it will
// now print data source with local path
externalLink.DataSource = "ExternalAccounts.xlsx";
Console.WriteLine("External Link Data Source After Removing Remote Path: " + externalLink.getDataSource());

// Change the absolute path of the workbook, it will also change the
// external link path
wb.AbsolutePath = "C:\\Files\\Extra\\";

// Now print the data source again
Console.WriteLine("External Link Data Source After Changing Workbook.AbsolutePath to Local Path: " + externalLink.getDataSource());

// Change the absolute path of the workbook to some remote path, it will
// again affect the external link path
wb.AbsolutePath = "http://www.aspose.com/WebFiles/ExcelFiles/";

// Now print the data source again
Console.WriteLine("External Link Data Source After Changing Workbook.AbsolutePath to Remote Path: " + externalLink.getDataSource());

If it does not fulfill your requirement, share your sample Excel file, program output, and expected output file. Also, share the steps to achieve this requirement using MS Excel for our reference.

Thanks, this helped :slight_smile:

@dr.doc,

You are welcome.