Example #1
0
		internal static void ImportNamedRanges(XmlReader reader, ExcelXmlWorkbook book, Worksheet ws)
		{
			if (!reader.IsEmptyElement)
			{
				while (reader.Read() && !(reader.Name == "Names" && reader.NodeType == XmlNodeType.EndElement))
				{
					if (reader.NodeType == XmlNodeType.Element)
					{
						if (reader.Name == "NamedRange")
						{
							Range range = null;
							string name = "";

							foreach (XmlReaderAttributeItem xa in reader.GetAttributes())
							{
								if (xa.LocalName == "Name" && xa.HasValue)
									name = xa.Value;

								if (xa.LocalName == "RefersTo" && xa.HasValue)
									range = new Range(xa.Value);
							}

							NamedRange nr = new NamedRange(range, name, ws);
							book.NamedRanges.Add(nr);
						}
					}
				}
			}
		}