title: C#. xlsx date cell import to DataTable by NPOI 2.0
body: <p>I'm tried to convert .xlsx file to DataTable format by using NPOI 2.0 library. It's OK, but I have a problem with convert to string date cell. When I try to use construction like row.GetCell(j).ToString() - it's threw exception "Cannot get numeric value from a text cell". I tried to use DateCellValue property, but it also threw this exception. With other cell formats it's work good.
  Function, that I use it's:</p>
  
  <pre><code>private DataTable xlsxToDT(string fileName)
      {
          DataTable table = new DataTable();
          XSSFWorkbook workbook = new XSSFWorkbook(new FileStream(fileName, FileMode.Open, FileAccess.Read));
          ISheet sheet = workbook.GetSheetAt(0);
          IRow headerRow = sheet.GetRow(0);
          int cellCount = headerRow.LastCellNum;
          for (int i = headerRow.FirstCellNum; i &lt; cellCount; i++)
          {
              DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
              table.Columns.Add(column);
          }
          int rowCount = sheet.LastRowNum;
          for (int i = (sheet.FirstRowNum); i &lt; sheet.LastRowNum; i++)
          {
              IRow row = sheet.GetRow(i);
              DataRow dataRow = table.NewRow();
              for (int j = row.FirstCellNum; j &lt; cellCount; j++)
              {
                  if (row.GetCell(j) != null)
                  {
                      //EXCEPTION GENERATING IN THIS CODE
                      dataRow[j] = row.GetCell(j).ToString();
                      ////////////////////////////
                  }
              }
              table.Rows.Add(dataRow);
          }
          workbook = null;
          sheet = null;
          return table;
      }
  </code></pre>
  
  <p>UPDATE:
  If I insert code like</p>
  
  <pre><code>row.GetCell(j).SetCellType(CellType.STRING);
  </code></pre>
  
  <p>in problem cell I have value like "36496.392581018517". Another cells converted correctly</p>