title: Export DataTable to Excel with Open Xml SDK in c#
body: <p>My program have ability to export some data and DataTable to Excel file (template)
  In the template I insert the data to some placeholders. It's works very good, but I need to insert a DataTable too...
  My sample code:</p>
  <pre><code>using (Stream OutStream = new MemoryStream())
  {
      // read teamplate
      using (var fileStream = File.OpenRead(templatePath))
          fileStream.CopyTo(OutStream);
  
      // exporting
      Exporting(OutStream);
           
      // to start
      OutStream.Seek(0L, SeekOrigin.Begin);
              
      // out
      using (var resultFile = File.Create(resultPath))
          OutStream.CopyTo(resultFile);
  </code></pre>
  <p>Next method to exporting</p>
  <pre><code>private void Exporting(Stream template)
  {
      using (var workbook = SpreadsheetDocument.Open(template, true, new OpenSettings                          { AutoSave = true }))
      {
          // Replace shared strings
          SharedStringTablePart sharedStringsPart = workbook.WorkbookPart.SharedStringTablePart;
          IEnumerable&lt;Text&gt; sharedStringTextElements = sharedStringsPart.SharedStringTable.Descendants&lt;Text&gt;();
             
          DoReplace(sharedStringTextElements);
          // Replace inline strings
          IEnumerable&lt;WorksheetPart&gt; worksheetParts = workbook.GetPartsOfType&lt;WorksheetPart&gt;();
            
          foreach (var worksheet in worksheetParts)
          {
              DoReplace(worksheet.Worksheet.Descendants&lt;Text&gt;());
          }
  
          int z = 40;
          foreach (System.Data.DataRow row in ExcelWorkXLSX.ToOut.Rows)
          {
              for (int i = 0; i &lt; row.ItemArray.Count(); i++)
              { 
                  ExcelWorkXLSX.InsertText(workbook, row.ItemArray.ElementAt(i).ToString(), getColumnName(i), Convert.ToUInt32(z)); }
                  z++;
              }
          } 
          
      }
  }
  </code></pre>
  <p>But this fragment to output DataTable slooooooooooooooooooooooowwwwwww...</p>
  <p>How can I export DataTable to Excel fast and truly?</p>