Beispiel #1
0
        private void SaveWriter()
        {
            try {
                using (Stream stream = _worksheetPart.GetStream(FileMode.Create, FileAccess.Write)) {
                    using (var writer = XmlWriter.Create(stream)) {
                        writer.WriteStartElement("worksheet", Constants.MainNamespace);
                        writer.WriteAttributeString("xmlns", "r", null, Constants.RelationshipNamespace);

                        if (Cells.Columns.ColumnsList.Count > 0)
                        {
                            Cells.Columns.Write(writer);
                        }

                        Cells.Write(writer);

                        if (MergedCells.Cells.Count > 0)
                        {
                            MergedCells.Write(writer);
                        }

                        AutoFilter.Write(writer);

                        writer.WriteEndElement();
                    }
                }
            } catch (ObjectDisposedException) {
                //Suppress any ObjectDisposedException thrown by multiple using statements
            } catch {
                throw;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Worksheet"/> class.
 /// </summary>
 /// <param name="styleSheet">The style sheet.</param>
 /// <param name="worksheetPart">The worksheet part.</param>
 internal Worksheet(Stylesheet styleSheet, PackagePart worksheetPart)
 {
     _styleSheet    = styleSheet;
     _worksheetPart = worksheetPart;
     MergedCells    = new MergedCells();
     Cells          = new Cells(_styleSheet, this);
     AutoFilter     = new AutoFilters();
 }