I am having problems trying to change the width of a cell or even columns programatically in VB.Net. I have created an excel object and I can get data into excel, but I can't seem to find the right way to format the cells and columns. Here is what I have thus far.
Dim xlApp As Microsoft.Office.Interop.Excel.Application Dim xlBook As Microsoft.Office.Interop.Excel.Workbook Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet Dim lb As IntegerxlApp = CreateObject(
"Excel.Application")xlBook = xlApp.Workbooks.Add()
xlSheet = xlBook.Worksheets(1)
For lb = 0 To ListBox1.Items.Count - 1 Step 1 Dim send As String Dim sendT As String Dim sendTE As Stringsend = ListBox1.Items.Item(lb)
sendT = ListBox2.Items.Item(lb)
sendTE = ListBox3.Items.Item(lb)
If lb >= 0 ThenxlSheet.Cells.Item((lb + 1), 1) = send
xlSheet.Cells.Item((lb + 1), 2) = sendT
xlSheet.Cells.Item((lb + 1), 3) = sendTE
End If NextxlBook.SaveAs(
"c:\Timesheet.xls")xlBook.Close()
xlApp =
NothingHow would I go about changing all the columns width in the sheet to a set value
Please help.

How do You Change the width of a Excel cell or columns in VB.Net
StuartFreeman
The following worked for me:
ActiveSheet.Columns("A:B").ColumnWidth = 13
The unit of measurement is points (as in the font being used).