You are almost there. You are already sorting through doc.WorkbookPart.Workbook.Sheets . All you have to do after this is insert the if statement to see if the sheet you are looking for is your current loop point by looking at the s.Name or s.Id
Alternatively, as indicated here , you can use LINQ to directly select a worksheet by name or id:
sID as Integer = doc.WorkbookPart.Workbook.Descendants(Sheet)().First(s => s.Name.Equals("First")).Id
or
sID as Integer = doc.WorkbookPart.Workbook.Descendants(Sheet)().First(s => s.Id.Equals(2)).Id
Once you have this ID, you can do
wsp As WorksheetPart = doc.WorkbookPart.GetPartById(sID)
I apologize if there are errors in this, I do it on a fast moving train using my brain compiler on the iPhone. Hopefully this should make you move in the right direction, at least.
source share