title: NPOI - saving workbook created from template file
body: <p>It is my 2nd time dealing with NPOI. I'm creating a workbook from a template excel file like this.</p>
  
  <pre><code>        string dldir = AppDomain.CurrentDomain.BaseDirectory + "Download\\excel\\";
          string uldir = AppDomain.CurrentDomain.BaseDirectory + "Upload\\default_export_file\\";
          string filename = DateTime.Now.ToString("yyyy-M-d") + "_" + user.first_name + "_" + query.default_export_filename;
  
          System.IO.File.Delete(Path.Combine(dldir, filename));
  
          //System.IO.File.Copy(Path.Combine(uldir, query.default_export_filename), Path.Combine(dldir, filename));
  
  
          HSSFWorkbook hssfwb;
          using (FileStream file = new FileStream(Path.Combine(uldir, query.default_export_filename), FileMode.Open, FileAccess.ReadWrite))
          {
              hssfwb = new HSSFWorkbook(file);
          }
  
          MemoryStream mstream = new MemoryStream();
          hssfwb.Write(mstream);
  
          FileStream xfile = new FileStream(Path.Combine(dldir, filename), FileMode.Create, System.IO.FileAccess.Write);
          byte[] bytes = new byte[mstream.Length];
          mstream.Read(bytes, 0, (int)mstream.Length);
          xfile.Write(bytes, 0, bytes.Length);
          xfile.Close();
          mstream.Close();
  </code></pre>
  
  <p>But when I checked the created file. It contains nothing. The size is correct. But the contents is just blanks. And I couldn't open it in MS Excel either. I repeated and traced the code but I can't seem to find what is causing it to just write blanks.</p>
  
  <p>Anyone knows why is this happening</p>
  
  <p>FYI: I'm using VS 2010, ASP.Net MVC 4 and NPOI 1.2.5 installed from the NuGet Gallery</p>