tobin46
asked on
Set Excel Column Width using VB.net
Hi!
I'm writing data to excel worksheet, but before I do, I want to format the sheet.
I've read many things online, forums, msdn, etc. and haven't found anything that provides an example of how to format a column's width.
Does anyone have a code example?
Thanks!
I'm writing data to excel worksheet, but before I do, I want to format the sheet.
I've read many things online, forums, msdn, etc. and haven't found anything that provides an example of how to format a column's width.
Does anyone have a code example?
Thanks!
ASKER
In vb.net when I use the syntax above, the columns is looking for a rowindex and column index....
I've tried the syntax above and it didn't work...
I've tried the syntax above and it didn't work...
Something like
Sheets("Sheet1").Columns(4 ).ColumnWi dth = 10.4
Sheets("Sheet1").Columns(4
ASKER
Well....I've set oSheet = oWorkBook.ActiveSheet....w ouldn't that be same thing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
When I select the property "columns" and use an integer I do not have the option to select "columnwidth".
As I mentioned before, the columns property is looking for a rowindex and columnindex. MSDN is telling me that the columns property is a Range object that represents all the columns on the worksheet.
As I mentioned before, the columns property is looking for a rowindex and columnindex. MSDN is telling me that the columns property is a Range object that represents all the columns on the worksheet.
ASKER
Hmmm....just tried the code:
oSheet.columns(integer).co lumnwidth =2.58 and it worked.....
Thanks!
oSheet.columns(integer).co
Thanks!
in Excel VBA, the syntax would be something like
Columns("G:G").ColumnWidth
Don't know about .NET. The object is specified in a different way "oSomething", but the rest should be similar.
cheers, teylyn