public StreamsheetParser(TextWriter output, bool startAtPrelude) { this._output = output; this._worksheet = (CT_Worksheet)this.Root; this._sectionsInOrder = new WriteDelegate[14] { this.WritePrelude, this._worksheet.Write_sheetPr, this._worksheet.Write_sheetViews, this._worksheet.Write_sheetFormatPr, this._worksheet.Write_cols, this._worksheet.Write_sheetData, this._worksheet.Write_mergeCells, this._worksheet.Write_hyperlinks, this._worksheet.Write_pageMargins, this._worksheet.Write_pageSetup, this._worksheet.Write_headerFooter, this._worksheet.Write_drawing, this._worksheet.Write_picture, this.WriteAfterword }; this._pendingCloseTag = null; if (startAtPrelude) { this._currentSection = StreamSheetSection.Prelude; } else { this.TryMoveToSection(StreamSheetSection.SheetData, 1); this._pendingCloseTag = CT_Worksheet.SheetDataElementName; new CT_SheetData().WriteOpenTag(this._output, CT_Worksheet.SheetDataElementName, 1, this.Namespaces, false); } }
public StreamsheetParser(TextWriter output, bool startAtPrelude) { _output = output; _worksheet = (CT_Worksheet)Root; _sectionsInOrder = new WriteDelegate[14] { WritePrelude, _worksheet.Write_sheetPr, _worksheet.Write_sheetViews, _worksheet.Write_sheetFormatPr, _worksheet.Write_cols, _worksheet.Write_sheetData, _worksheet.Write_mergeCells, _worksheet.Write_hyperlinks, _worksheet.Write_pageMargins, _worksheet.Write_pageSetup, _worksheet.Write_headerFooter, _worksheet.Write_drawing, _worksheet.Write_picture, WriteAfterword }; _pendingCloseTag = null; if (startAtPrelude) { _currentSection = StreamSheetSection.Prelude; return; } TryMoveToSection(StreamSheetSection.SheetData, 1); _pendingCloseTag = CT_Worksheet.SheetDataElementName; new CT_SheetData().WriteOpenTag(_output, CT_Worksheet.SheetDataElementName, 1, Namespaces, root: false); }
private void FastForward(StreamSheetSection section, int depth) { for (int i = (int)(this._currentSection + 1); i <= (int)(section - 1); i++) { this._sectionsInOrder[i](this._output, depth, this.Namespaces); } this._currentSection = section; }
private void WriteStandaloneTag(OoxmlComplexType tag, StreamSheetSection section, string tagname) { if (tag != null) { if (this._currentSection != section) { this.TryMoveToSection(section, 1); } tag.Write(this._output, tagname, 1, this.Namespaces); } }
private void TryMoveToSection(StreamSheetSection section, int depth) { if (this._currentSection != section) { if (section <= this._currentSection) { throw new FatalException(); } this.FinishCurrentTag(); this.FastForward(section, depth); } }
private void WriteTagInCollection <TCol>(OoxmlComplexType tag, StreamSheetSection section, string tagname, string coltagname) where TCol : OoxmlComplexType, new() { if (tag != null) { if (_currentSection != section) { TryMoveToSection(section, 1); _pendingCloseTag = coltagname; new TCol().WriteOpenTag(_output, coltagname, 1, Namespaces, root: false); } tag.Write(_output, tagname, 2, Namespaces); } }
private void WriteTagInCollection <TCol>(OoxmlComplexType tag, StreamSheetSection section, string tagname, string coltagname) where TCol : OoxmlComplexType, new() { if (tag != null) { if (this._currentSection != section) { this.TryMoveToSection(section, 1); this._pendingCloseTag = coltagname; TCol val = new TCol(); val.WriteOpenTag(this._output, coltagname, 1, this.Namespaces, false); } tag.Write(this._output, tagname, 2, this.Namespaces); } }