private void ReadWorkbookRels(Stream xmlFileStream) { using (XmlReader reader = XmlReader.Create(xmlFileStream)) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.LocalName == N_rel) { string rid = reader.GetAttribute(A_id); for (int i = 0; i < sheets.Count; i++) { XlsxWorksheet tempSheet = sheets[i]; if (tempSheet.RID == rid) { tempSheet.Path = reader.GetAttribute(A_target); sheets[i] = tempSheet; break; } } } } xmlFileStream.Close(); } }
private void ReadWorkbook(Stream xmlFileStream) { sheets = new List <XlsxWorksheet>(); using (XmlReader reader = XmlReader.Create(xmlFileStream)) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.LocalName == N_sheet) { var sheetIdText = reader.GetAttribute(A_sheetId); Debug.Assert(sheetIdText != null); var sheetName = reader.GetAttribute(A_name); var sheetId = int.Parse(sheetIdText); var rid = reader.GetAttribute(A_rid); var sheet = new XlsxWorksheet(sheetName, sheetId, rid); sheets.Add(sheet); } } xmlFileStream.Close(); } }