title: npoi date format
body: <p>I am using NPOI 1.2.5.0 , Visual Studio 2008. There is a date column in the spreadsheet. I </p>
  
  <p>observed that, if I open file in Microsoft Excel, set size of column to autoset , save it , </p>
  
  <p>it goes fine.I can't use this solution, because there is no excel installed on Production </p>
  
  <p>PC.</p>
  
  <p>Otherwise, the date column shows #### instead of date, when I process other logic/coding </p>
  
  <p>using NPOI and save this file. And I open excel, it says file is corrupted, needs </p>
  
  <p>recovered, data may be lost. If I click "yes", it does recover file and show 
  everything correct.</p>
  
  <p>I found that this can be solved, if I open file autoset date column save excel using </p>
  
  <p>Microsoft Excel. After processing using NPOI .net code, it does open ok.</p>
  
  <ol>
  <li>So I decided to do autoset thr' code using NPOI, it does not increase width of date </li>
  </ol>
  
  <p>column, instead it shows numbers there. </p>
  
  <p>I had written following code to set Date Format, but it is displaying number instead of </p>
  
  <p>date. I tried autoset code before OR after this block, no change.</p>
  
  <pre><code>for (int i = 0; i &lt;= nTotalRows; i++)
              {
                  HSSFCellStyle cellStyle = (HSSFCellStyle)templateWorkbook.CreateCellStyle();
                  HSSFCell Cell = (HSSFCell)exlSheet.GetRow(i).GetCell(nCheckColumn);
                  //(HSSFCell)exlSheet.Sheet.get .SetDefaultColumnStyle(nCheckColumn,
                  cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("mm-dd-yy");
                  Cell.CellStyle = cellStyle;
                  MemoryStream ms = new MemoryStream();
                  templateWorkbook.Write(ms);
                  ms.Close();
                  FileStream fs1 = new FileStream(strFilePath, FileMode.Create);
                  templateWorkbook.Write(fs1);
                  fs1.Close();
              }
  </code></pre>
  
  <p>Please suggest a solution for this. I was searching for Getcolumn to set Dataformat to </p>
  
  <p>complete column instead of cell. </p>
  
  <p>sham</p>