title: Set Column Width in C# (Interop.Excel)
body: <p>I have a c# script which successfully opens a specified Excel workbook, delete the first row and save it down as a csv format. </p>
  
  <p>I have an issue that the CSV saves down as a standard col width of 8.43 I would like to change the col width of col J as 17.00 before saving down the csv. </p>
  
  <p>Can someone please advise how I set the Col width of col J to 17.</p>
  
  <p>I am unable to use VBA / Macros due to the process. </p>
  
  <p>I am using; </p>
  
  <pre><code>myWorkSheet.Columns["J:J"].ColumnWidth = 17.57;
  </code></pre>
  
  <p>This however leads to an object does not contain definition for 'ColumnWidth' screenshot attached. <a href="https://i.stack.imgur.com/uUpcd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uUpcd.png" alt="enter image description here"></a></p>
  
  <p>Full code below;</p>
  
  <pre><code>        public void DeleteRows(string OriginalFileName,String NewFileName)
      {
          Microsoft.Office.Interop.Excel.Application myApp;
          Microsoft.Office.Interop.Excel.Workbook myWorkBook;
          Microsoft.Office.Interop.Excel.Worksheet myWorkSheet;
          Microsoft.Office.Interop.Excel.Range range;
          myApp = new Microsoft.Office.Interop.Excel.Application();
          myWorkBook = myApp.Workbooks.Open(OriginalFileName, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
          myWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)myWorkBook.Worksheets.get_Item(1);
          range = (Microsoft.Office.Interop.Excel.Range)myWorkSheet.Application.Rows[1, Type.Missing];
          range.Select();
          range.Delete(Microsoft.Office.Interop.Excel.XlDirection.xlUp);
          //Microsoft.Office.Interop.Excel.Range ThisRange1 = myWorkSheet.get_Range("J:J",System.Type.Missing);
          myWorkSheet.Columns["J:J"].ColumnWidth = 17.57; //ERRORLINE
          myApp.DisplayAlerts = false;
          myWorkSheet.SaveAs(NewFileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlCSVWindows, Type.Missing, Type.Missing, false, false, false, XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing);
          myWorkBook.Close(false);
          myApp.Quit();
      }
  </code></pre>