title: how to create a excel file in azure function App by using timer trigger
body: <p>I created a method in my azure function app  which gets the static data from a class and stores it to a excel file I am storing the  excel file in a storage account. when I run the method a empty Excel file is created in storage account</p>
  <ol>
  <li><p>How to Create a Excel file in Azure function-app</p>
  </li>
  <li><p>How to store a data in Excel file</p>
  <pre><code>[FunctionName(&quot;Function1&quot;)]
  public static void Run([TimerTrigger(&quot;0 */5 * * * *&quot;)]TimerInfo myTimer, ILogger log, [Blob(&quot;name/empchange.csv&quot;, FileAccess.Read, Connection = &quot;AzureWebJobsStorage&quot;)] Stream myblob, [Blob(&quot;name/TestNewExcel.xlsx&quot;, FileAccess.Write, Connection = &quot;AzureWebJobsStorage&quot;)] TextWriter outputblob)
  {
      log.LogInformation($&quot;C# Timer trigger function executed at: {DateTime.Now}&quot;);
  
      try
      {
          // Read CSV File
          ReadCsvFile(myblob);
          // create Excel File
          CreateExcel(outputblob);
      }
      catch (Exception ex)
      {
          Console.WriteLine(ex);
      }
  }
  </code></pre>
  </li>
  </ol>
  <p><strong>Excel method:</strong></p>
  <pre><code>  static void CreateExcel(TextWriter outputblob)
      {
          data clsdata = new data();
          DataTable table = clsdata.Getdata();
  
          using (SpreadsheetDocument document = SpreadsheetDocument.Create(outputblob.ToString(), SpreadsheetDocumentType.Workbook))
          {
              WorkbookPart workbookPart = document.AddWorkbookPart();
              workbookPart.Workbook = new  Workbook();
  
              WorksheetPart worksheetPart = workbookPart.AddNewPart&lt;WorksheetPart&gt;();
              var sheetData = new SheetData();
              worksheetPart.Worksheet = new Worksheet(sheetData);
  
              Sheets sheets = workbookPart.Workbook.AppendChild(new Sheets());
              Sheet sheet = new Sheet() { Id = workbookPart.GetIdOfPart(worksheetPart), SheetId = 1, Name = &quot;Sheet1&quot; };
  
              sheets.Append(sheet);
  
              Row headerRow = new Row();
  
              List&lt;String&gt; columns = new List&lt;string&gt;();
              foreach (DataColumn column in table.Columns)
              {
                  columns.Add(column.ColumnName);
  
                  Cell cell = new Cell();
                  cell.DataType = CellValues.String;
                  cell.CellValue = new CellValue(column.ColumnName);
                  headerRow.AppendChild(cell);
              }
  
              sheetData.AppendChild(headerRow);
  
              foreach (System.Data.DataRow dsrow in table.Rows)
              {
                  Row newRow = new Row();
                  foreach (String col in columns)
                  {
                      Cell cell = new Cell();
                      cell.DataType = CellValues.String;
                      cell.CellValue = new CellValue(dsrow[col].ToString());
                      newRow.AppendChild(cell);
                  }
  
                  sheetData.AppendChild(newRow);
              }
              workbookPart.Workbook.Save();
          }
      }
  </code></pre>
  <p>my Azure function Bindings:</p>
  <pre><code>    {
    &quot;bindings&quot;: [
      {
        &quot;name&quot;: &quot;myblob&quot;,
        &quot;type&quot;: &quot;blob&quot;,
        &quot;path&quot;: &quot;name/empchange.csv&quot;,
        &quot;direction&quot;: &quot;in&quot;,
        &quot;connection&quot;: &quot;AzureWebJobsStorage&quot;
  
      },
      {
        &quot;name&quot;: &quot;outputblob&quot;,
        &quot;type&quot;: &quot;blob&quot;,
        &quot;path&quot;: &quot;name/ExcelFile.xlsx&quot;,
        &quot;direction&quot;: &quot;out&quot;,
        &quot;connection&quot;: &quot;AzureWebJobsStorage&quot;
  
      }
    ],
    &quot;disabled&quot;: false
  }
  
  </code></pre>