private void WriteStandaloneTag(OoxmlComplexType tag, StreamSheetSection section, string tagname)
 {
     if (tag != null)
     {
         if (_currentSection != section)
         {
             TryMoveToSection(section, 1);
         }
         tag.Write(_output, tagname, 1, Namespaces);
     }
 }
 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);
     }
 }
 public void WriteTag(OoxmlComplexType tag)
 {
     if (tag == null)
     {
         return;
     }
     if (tag is CT_SheetPr)
     {
         WriteSheetProperties((CT_SheetPr)tag);
         return;
     }
     if (tag is CT_SheetView)
     {
         WriteSheetView((CT_SheetView)tag);
         return;
     }
     if (tag is CT_SheetFormatPr)
     {
         WriteSheetFormatProperties((CT_SheetFormatPr)tag);
         return;
     }
     if (tag is CT_Col)
     {
         WriteColumnProperty((CT_Col)tag);
         return;
     }
     if (tag is CT_Row)
     {
         WriteRow((CT_Row)tag);
         return;
     }
     if (tag is CT_MergeCell)
     {
         WriteMergedCell((CT_MergeCell)tag);
         return;
     }
     if (tag is CT_Hyperlink)
     {
         WriteHyperlink((CT_Hyperlink)tag);
         return;
     }
     if (tag is CT_PageMargins)
     {
         WritePageMargins((CT_PageMargins)tag);
         return;
     }
     if (tag is CT_PageSetup)
     {
         WritePageSetup((CT_PageSetup)tag);
         return;
     }
     if (tag is CT_HeaderFooter)
     {
         WriteHeaderFooter((CT_HeaderFooter)tag);
         return;
     }
     if (tag is CT_Drawing)
     {
         WriteDrawing((CT_Drawing)tag);
         return;
     }
     if (tag is CT_SheetBackgroundPicture)
     {
         WritePicture((CT_SheetBackgroundPicture)tag);
         return;
     }
     throw new FatalException();
 }