title: How to read excel file data using memory stream?
body: <p>I want to read Excel file from JSON data which I am sending from ARC, Can anyone help me to sorted out?</p>
  
  <pre><code>public bool ControlAttachment(AttachmentFile file)
  {
      try
      {
          if (file != null &amp;&amp; file.File != null)
          {
              string xlsfile = file.File;
              string [] xls = {"application/excel","application/vnd.msexcel","xls","xlsx","application/vnd.ms-excel",};
  
              if (xls.ToList().Contains(file.FileType.Trim()))
              {
                  file.FileType = ".xls";
                  byte[] contents = Convert.FromBase64String(xlsfile);
                  string LogFilePaths = ConfigurationManager.AppSettings["ExcelMapperPath"];
                  string fileName = file.FileName.Split('.')[0] + file.FileType;
                  string LogFile = HttpContext.Current.Server.MapPath(LogFilePaths + file.FileName.Split('.')[0] + file.FileType);
  
                  System.IO.File.WriteAllBytes(LogFile, contents);
  
                  if (!File.Exists(LogFile))
                  { 
                      File.Create(LogFile).Dispose();
                  }
                  MemoryStream ms = new MemoryStream();
                  using (var fs = new FileStream(LogFile, FileMode.Open, FileAccess.Write))
                  { 
                          ms.CopyTo(fs);
                          ms.Dispose();
                  }
              }
          }
          return true;
      }
      catch 
      {
          return false;
      }
  }
  </code></pre>