How to remove external links in an Excel document (XLSX) using OpenXML

Viewed 81

I have a relatively simple question, but as in my opinion OpenXML has little documentation, I do not understand the following properly.

First off, we are talking about a XLSX file, which I am trying to open and remove the "external links". These links can be found in the XLSX file, when one unpacks it and navigates to xl/externalLinks. I would like to "break" all these links using OpenXML.

var wbPart = spreadsheetDocument.WorkbookPart;
foreach ExternalWorkbookPart ewp in wbPart.ExternalWorkbookParts){
   // Delete the link 
}

What I can't seem to understand is whether to use DeleteExternalRelationship, DeletePart or DeleteReferenceRelationship. I want to do something similar to "break external links" in Excel.

I have looked at the documentation, but perhaps I am missing something. It does not seem to explain the difference between these methods or their definitions.

0 Answers
Related