none
How to delete a connection? RRS feed

  • Question

  • I am trying to create a snapshot from a full workbook downloaded from Excel services web service.  Excel services does not preserve page breaks so I am using OpenXML sdk to remove data connections from the workbook and copy/paste cell values over formulas.

    All is well except that after deleting connections the workbook throws the "unreadable content" error when the user opens it in excel.  The workbook still opens and the repair message says the "connections.xml" file was repaired.  The code I am using is:

         For i As Integer = wbPart.ConnectionsPart.Connections.Count - 1 To 0 Step -1
                       Dim conn As Connection = wbPart.ConnectionsPart.Connections(i)
                       conn.Deleted = True
                 Next

    This works fine to delete the connections, but obviously something else is required to maintain workbook integrity.  Is there another attribute of the connection node I should be changing or some other part of the workbook to update after deleting a connection?  Thanks in advance,  Marcus


    scholz

    Friday, February 27, 2015 6:02 AM

Answers

  • Hi scholz,

    After you remove the connections, you'll also have to remove the references to these connections. For example, if you create a QueryTablePart and add a QueryTable which refers to a ConnectionId. You need to remove this QueryTable along with the Connection so that the Excel application can properly resolve the spreadsheet.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, March 2, 2015 7:57 AM
    Moderator