private void ReadSharedStrings(Stream xmlFileStream) { if (null == xmlFileStream) { return; } _SST = new XlsxSST(); using (XmlReader reader = XmlReader.Create(xmlFileStream)) { // There are multiple <t> in a <si>. Concatenate <t> within an <si>. bool bAddStringItem = false; bool bSetStringItem = false; string sStringItem = ""; while (reader.Read()) { //DumpNode(reader); // There are multiple <t> in a <si>. Concatenate <t> within an <si>. if (reader.NodeType == XmlNodeType.Element && reader.LocalName == N_si) { // Do not add the string item until the next string item is read. if (bAddStringItem) { // Add the string item to XlsxSST. _SST.Add(sStringItem); } else { // Add the string items from here on. bAddStringItem = true; } // Reset the string item. sStringItem = ""; bSetStringItem = false; } if (reader.NodeType == XmlNodeType.Element && reader.LocalName == N_t) { // Append to the string item. string contineText = reader.ReadElementContentAsString(); if (!bSetStringItem) { //Console.WriteLine(contineText); sStringItem = contineText; bSetStringItem = true; } } } // Do not add the last string item unless we have read previous string items. if (bAddStringItem) { // Add the string item to XlsxSST. _SST.Add(sStringItem); } xmlFileStream.Close(); } }
private void ReadSharedStrings(Stream xmlFileStream) { if (null == xmlFileStream) { return; } _SST = new XlsxSST(); using (XmlReader reader = XmlReader.Create(xmlFileStream)) { // There are multiple <t> in a <si>. Concatenate <t> within an <si>. bool bAddStringItem = false; string sStringItem = ""; while (reader.Read()) { // There are multiple <t> in a <si>. Concatenate <t> within an <si>. if (reader.NodeType == XmlNodeType.Element && reader.LocalName == N_si) { // Do not add the string item until the next string item is read. if (bAddStringItem) { // Add the string item to XlsxSST. _SST.Add(sStringItem); } else { // Add the string items from here on. bAddStringItem = true; } // Reset the string item. sStringItem = ""; } if (reader.NodeType == XmlNodeType.Element && reader.LocalName == N_t) { // Skip phonetic string data. if (sStringItem.Length == 0) { // Add to the string item. sStringItem = reader.ReadElementContentAsString(); } } } // Do not add the last string item unless we have read previous string items. if (bAddStringItem) { // Add the string item to XlsxSST. _SST.Add(sStringItem); } xmlFileStream.Close(); } }
private void ReadSharedStrings(Stream xmlFileStream) { if (null == xmlFileStream) return; _SST = new XlsxSST(); using (XmlReader reader = XmlReader.Create(xmlFileStream)) { // There are multiple <t> in a <si>. Concatenate <t> within an <si>. bool bAddStringItem = false; string sStringItem = ""; while (reader.Read()) { // There are multiple <t> in a <si>. Concatenate <t> within an <si>. if (reader.NodeType == XmlNodeType.Element && reader.LocalName == N_si) { // Do not add the string item until the next string item is read. if (bAddStringItem) { // Add the string item to XlsxSST. _SST.Add(sStringItem); } else { // Add the string items from here on. bAddStringItem = true; } // Reset the string item. sStringItem = ""; } if (reader.NodeType == XmlNodeType.Element && reader.LocalName == N_t) { // Skip phonetic string data. if (sStringItem.Length == 0) { // Add to the string item. sStringItem = reader.ReadElementContentAsString(); } } } // Do not add the last string item unless we have read previous string items. if (bAddStringItem) { // Add the string item to XlsxSST. _SST.Add(sStringItem); } xmlFileStream.Close(); } }
private void ReadSharedStrings(Stream xmlFileStream) { if (null == xmlFileStream) return; _SST = new XlsxSST(); using (XmlReader reader = XmlReader.Create(xmlFileStream)) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == N_t) { _SST.Add(reader.ReadElementContentAsString()); } } xmlFileStream.Close(); } }
private void ReadSharedStrings(Stream xmlFileStream) { if (xmlFileStream != null) { this._SST = new XlsxSST(); using (XmlReader reader = XmlReader.Create(xmlFileStream)) { bool flag = false; string item = ""; while (reader.Read()) { if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "si")) { if (flag) { this._SST.Add(item); } else { flag = true; } item = ""; } if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "t")) { item = item + reader.ReadElementContentAsString(); } } if (flag) { this._SST.Add(item); } xmlFileStream.Close(); } } }
private XlsxSST ReadSharedStrings(Stream xmlFileStream) { if (null == xmlFileStream) { return(null); } var _SST = new XlsxSST(); using (XmlReader reader = XmlReader.Create(xmlFileStream)) { // Skip phonetic string data. bool bSkipPhonetic = false; // There are multiple <t> in a <si>. Concatenate <t> within an <si>. bool bAddStringItem = false; string sStringItem = ""; while (reader.Read()) { // There are multiple <t> in a <si>. Concatenate <t> within an <si>. if (reader.NodeType == XmlNodeType.Element && reader.LocalName == N_si) { // Do not add the string item until the next string item is read. if (bAddStringItem) { // Add the string item to XlsxSST. _SST.Add(sStringItem); } else { // Add the string items from here on. bAddStringItem = true; } // Reset the string item. sStringItem = ""; } else if (reader.NodeType == XmlNodeType.Element && reader.LocalName == N_t) { // Skip phonetic string data. if (!bSkipPhonetic) { // Append to the string item. sStringItem += reader.ReadElementContentAsString(); } } if (reader.LocalName == "rPh") { // Phonetic items represents pronunciation hints for some East Asian languages. // In the file 'xl/sharedStrings.xml', the phonetic properties appear like: // <si> // <t>(a japanese text in KANJI)</t> // <rPh sb="0" eb="1"> // <t>(its pronounciation in KATAKANA)</t> // </rPh> // </si> if (reader.NodeType == XmlNodeType.Element) { bSkipPhonetic = true; } else if (reader.NodeType == XmlNodeType.EndElement) { bSkipPhonetic = false; } } } // Do not add the last string item unless we have read previous string items. if (bAddStringItem) { // Add the string item to XlsxSST. _SST.Add(sStringItem); } } return(_SST); }
public XlsxWorkbook(List <XlsxWorksheet> sheets, XlsxSST _SST, XlsxStyles _Styles) { this.sheets = sheets; this._SST = _SST; this._Styles = _Styles; }