title: Text to column in Excel
body: <p>I have an excel sheet containing single column and multiple rows like: </p>
  
  <pre><code>000500114673HY340216-00       CT TAPING WORK DTYPE-OSKF 245 TWB.T H/C 37990110000250000100
  </code></pre>
  
  <p>I am trying to create a new Excel file through my C# code, but not getting the desired result. In my new Excel file I need six columns with each column assigned a particular range, say for first column 12, for second 20 and so on (spaces also included). I used the text to column method, but I'm not able to parse it to fixed width. My code sample is: </p>
  
  <pre><code>xlAppNew = new Application();
  xlAppNew.DisplayAlerts = true;
  workbooks = xlAppNew.Workbooks;                   
  workbook = workbooks.Open(@filepath, 0, true, 1, "", "", true,
             Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t",
             false, false, 0, true, 1, 0);
  xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets.get_Item(1);        
  ((Range)xlAppNew.Cells[1, 1]).EntireColumn.TextToColumns(Type.Missing,
             Microsoft.Office.Interop.Excel.XlTextParsingType.xlFixedWidth,
             Microsoft.Office.Interop.Excel.XlTextQualifier.xlTextQualifierNone,
             Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
             Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
             Type.Missing);
  </code></pre>
  
  <p>I think the problem lies with the fourth last parameter, the fieldinfo object which I am not able to provide properly, I also used the array object, but it produced error. I took help from this question <a href="https://stackoverflow.com/questions/4945621/c-sharp-excel-text-to-column-problem">4945621</a>. But the exact solution is not provided there. </p>