title: Encoding and Decoding excel file as Base64 string
body: <p>This is for a <code>Windows Console App</code></p>
  
  <p>I am saving an <code>Excel</code> file that I am using as a template for reports as a <code>Base64</code> <code>string</code>. using the code below to encode the file as a <code>base64</code> <code>string</code>. I then store it in an <code>SQL</code> Database as <code>NVARCHAR(MAX)</code></p>
  
  <pre><code>Stream myStream = null;
  string base64String;
  OpenFileDialog openFileDialog1 = new OpenFileDialog();
  MemoryStream ms = new MemoryStream();
  openFileDialog1.InitialDirectory = "c:\\";
  openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
  openFileDialog1.FilterIndex = 2;
  openFileDialog1.RestoreDirectory = true;
  using (myStream)
  {
      myStream.CopyTo(ms);
      byte[] excelBytes = ms.ToArray();
      base64String = Convert.ToBase64String(excelBytes, Base64FormattingOptions.None);
      FileNameTxt.Text = openFileDialog1.FileName;
  }
  </code></pre>
  
  <p>I then retrieve this file and decode the string and create a <code>ClosedXML</code> excel file.</p>
  
  <pre><code>try
  {
      connection.Open();
      SqlDataReader reader = command.ExecuteReader();
      while (reader.Read())
      {
          StoredFile = reader["StoredFile"].ToString();
  
      }
      reader.Close();
  
      wb = workBook(StoredFile);
  }
  
  public static XLWorkbook workBook(string File)
  {
      byte[] data = System.Convert.FromBase64String(File);
      MemoryStream ms = new MemoryStream(data);
  
      XLWorkbook wb = new XLWorkbook(ms);
      return wb;
  }
  </code></pre>
  
  <p>The problem is that the end result is a workbook that has lost some of its formatting. mainly appears to have only affected border formatting. </p>
  
  <p>I don't know if it is an issue with the encoding, decoding or generation of new file using <code>ClosedXML</code> that is causing the issue. Any direction or thoughts are greatly appreciated. </p>