Comment puis-je obtenir le Worksheetpart à partir du nom ou de la feuille ID dans OpenXML?

Le code suivant crée un XLSX, ajoute deux feuilles de calcul avec des données. Je veux être en mesure d'obtenir la feuille de calcul, plus tard, d'après le nom (ou, de préférence, l'id) afin que je puisse ajouter/modifier des feuilles à un point plus tard dans le temps. Je suis coincé sur la façon d'obtenir à nouveau la fiche d'où le code est incomplet ci-dessous.

    Sub Main()
Using doc As SpreadsheetDocument = SpreadsheetDocument.Create(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "c:\temp\fubar.xlsx"), SpreadsheetDocumentType.Workbook)
Dim currSheet As WorksheetPart
' create the workbook
doc.AddWorkbookPart()
doc.WorkbookPart.Workbook = New Workbook()
doc.WorkbookPart.Workbook.AppendChild(New Sheets())
currSheet = InsertWorksheet(doc.WorkbookPart, "First")
currSheet.Worksheet.First().AppendChild(New Row())
currSheet.Worksheet.First().First().AppendChild(New Cell() With { _
.CellValue = New CellValue("1") _
})
currSheet = InsertWorksheet(doc.WorkbookPart, "Second")
currSheet.Worksheet.First().AppendChild(New Row())
currSheet.Worksheet.First().First().AppendChild(New Cell() With { _
.CellValue = New CellValue("1") _
})
For Each s As Sheet In doc.WorkbookPart.Workbook.Sheets
System.Diagnostics.Debug.WriteLine(s.Id)
System.Diagnostics.Debug.WriteLine(s.SheetId)
Next
cursheet = ... 'Get worksheetpart with name "First"
cursheet = ...  'Get worksheet with sheetid = 2
doc.WorkbookPart.Workbook.Save()
End Using
End Sub
Private Function InsertWorksheet(ByVal workbookPart As WorkbookPart, SheetName As String) As WorksheetPart
' Add a new worksheet part to the workbook.
Dim newWorksheetPart As WorksheetPart = workbookPart.AddNewPart(Of WorksheetPart)()
newWorksheetPart.Worksheet = New Worksheet(New SheetData)
newWorksheetPart.Worksheet.Save()
Dim sheets As Sheets = workbookPart.Workbook.GetFirstChild(Of Sheets)()
Dim relationshipId As String = workbookPart.GetIdOfPart(newWorksheetPart)
' Get a unique ID for the new sheet.
Dim sheetId As UInteger = 1
If (sheets.Elements(Of Sheet).Count() > 0) Then
sheetId = sheets.Elements(Of Sheet).Select(Function(s) s.SheetId.Value).Max() + 1
End If
' Add the new worksheet and associate it with the workbook.
Dim sheet As Sheet = New Sheet
sheet.Id = relationshipId
sheet.SheetId = sheetId
sheet.Name = sheetName
sheets.Append(sheet)
workbookPart.Workbook.Save()
Return newWorksheetPart
End Function

OriginalL'auteur WhiskerBiscuit | 2013-05-23