title: Creating Excel files directly on blob
body: <p>I have following function which works fine when saving to disk. I am executing the code from an Azure function. Is there anyway to to write to a blob storage instead without saving to disk?</p>
  
  <pre><code>private void ExportDataSet(DataTable ds, string destination)
  {
      using (var workbook = SpreadsheetDocument.Create(destination, DocumentFormat.OpenXml.SpreadsheetDocumentType.Workbook))
      {
          var workbookPart = workbook.AddWorkbookPart();
  
          workbook.WorkbookPart.Workbook = new DocumentFormat.OpenXml.Spreadsheet.Workbook();
  
          workbook.WorkbookPart.Workbook.Sheets = new DocumentFormat.OpenXml.Spreadsheet.Sheets();
  
          var sheetPart = workbook.WorkbookPart.AddNewPart&lt;WorksheetPart&gt;();
          var sheetData = new DocumentFormat.OpenXml.Spreadsheet.SheetData();
          sheetPart.Worksheet = new DocumentFormat.OpenXml.Spreadsheet.Worksheet(sheetData);
  
          DocumentFormat.OpenXml.Spreadsheet.Sheets sheets = workbook.WorkbookPart.Workbook.GetFirstChild&lt;DocumentFormat.OpenXml.Spreadsheet.Sheets&gt;();
          string relationshipId = workbook.WorkbookPart.GetIdOfPart(sheetPart);
  
          uint sheetId = 1;
          if (sheets.Elements&lt;DocumentFormat.OpenXml.Spreadsheet.Sheet&gt;().Count() &gt; 0)
          {
              sheetId =
                  sheets.Elements&lt;DocumentFormat.OpenXml.Spreadsheet.Sheet&gt;().Select(s =&gt; s.SheetId.Value).Max() + 1;
          }
  
          DocumentFormat.OpenXml.Spreadsheet.Sheet sheet = new DocumentFormat.OpenXml.Spreadsheet.Sheet() { Id = relationshipId, SheetId = sheetId, Name = "Sites" };
          sheets.Append(sheet);
  
          DocumentFormat.OpenXml.Spreadsheet.Row headerRow = new DocumentFormat.OpenXml.Spreadsheet.Row();
  
          List&lt;String&gt; columns = new List&lt;string&gt;();
          foreach (System.Data.DataColumn column in ds.Columns)
          {
              columns.Add(column.ColumnName);
  
              DocumentFormat.OpenXml.Spreadsheet.Cell cell = new DocumentFormat.OpenXml.Spreadsheet.Cell();
              cell.DataType = DocumentFormat.OpenXml.Spreadsheet.CellValues.String;
              cell.CellValue = new DocumentFormat.OpenXml.Spreadsheet.CellValue(column.ColumnName);
              headerRow.AppendChild(cell);
          }   
  
          sheetData.AppendChild(headerRow);
  
          foreach (System.Data.DataRow dsrow in ds.Rows)
          {
              DocumentFormat.OpenXml.Spreadsheet.Row newRow = new DocumentFormat.OpenXml.Spreadsheet.Row();
              foreach (String col in columns)
              {
                  DocumentFormat.OpenXml.Spreadsheet.Cell cell = new DocumentFormat.OpenXml.Spreadsheet.Cell();
                  cell.DataType = DocumentFormat.OpenXml.Spreadsheet.CellValues.String;
                  cell.CellValue = new DocumentFormat.OpenXml.Spreadsheet.CellValue(dsrow[col].ToString()); //
                  newRow.AppendChild(cell);
              }    
              sheetData.AppendChild(newRow);
          }                
      }
  }
  </code></pre>
  
  <p>I would expect you maybe could save to a Stream?</p>