Пример #1
0
        public void AddSheet(Sheet sheet)
        {
            if(sheet == null)
            {
                throw new ArgumentNullException("You cannot add null sheet to the workbook");
            }

            this._sheets.Add(sheet);
        }
Пример #2
0
 public void RemoveSheet(Sheet sheet)
 {
     this._sheets.Remove(sheet);
 }
Пример #3
0
        private void PopulateSheet(Sheet sheet, string sheetXml)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(sheetXml);

            XmlNode sheetData = this.FindNodeByNameRecursively("sheetData", xmlDoc);

            foreach(XmlNode row in sheetData)
            {
                foreach(XmlNode cell in row)
                {
                    XmlNode type = cell.Attributes.GetNamedItem("t");
                    string typeName = type != null ? type.InnerText : String.Empty;
                    string cellCoords = cell.Attributes.GetNamedItem("r").InnerText;
                    XmlNode cellValue = this.FindNodeByNameRecursively("v", cell);
                    string value = cellValue != null ? cellValue.InnerText : null;

                    if (!string.Equals(typeName, "s"))
                    {
                        sheet[cellCoords] = value;
                    }
                    else
                    {
                        int index = int.Parse(value);
                        sheet[cellCoords] = this.Workbook.GetSharedString(index);
                    }
                }
            }
        }