title: Read Excel file in web api
body: <p>Currently I pass fully qualified path into the input control. I am passing it into web api via angularjs. </p>
  
  <p>Instead of passing the path, I would like to just click the button, point to excel file on my local hard drive, pass that file into the web api, and then read the file inside web api. </p>
  
  <p>Internet search results are not helping. </p>
  
  <p>Here is my code. </p>
  
  <pre><code>public RowTable ProcessFile([FromBody] string filePath)
  {
      if (string.IsNullOrEmpty(filePath))
      {
          throw new Exception("file path is null or empty.");
      }
  
      using (var pck = new OfficeOpenXml.ExcelPackage())
      {
          using (var stream = File.OpenRead(filePath))
          {
              pck.Load(stream);
          }
          var ws = pck.Workbook.Worksheets.First();
          .. process excel file in C# here..   
      }
  </code></pre>
  
  <p>... some more code here.
      }</p>
  
  <p>html code..</p>
  
  <pre><code>&lt;form novalidate class="simple-form"&gt;
      &lt;input type="text" style="width:900px" placeholder="excel file path .." data-ng-model="filePath" /&gt;
      &lt;input type="submit" data-ng-click="LoadFilePath()" value="Load Rates Table Excel File Data." /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>AngularJS code ...</p>
  
  <pre><code>var app = angular.module('app', ['ngTouch', 'ui.grid']);
  
  app.controller('fileCtrl', ['$scope', '$http', function ($scope, $http) {
      //dataLoadError
      $scope.LoadFilePath = function () {
          $http
              .post('http://localhost:1229/api/Rates/processfile', '"' + $scope.filePath + '"')
              .success(function (data) {
                  $scope.Rates = data.Rates;
                  $scope.InsertSQL = data.InsertSQL;
              })
              .error(function (data) {
  
              })
              ;
      }
  }]);
  </code></pre>