Thank you. So I did access the link, download the extended MS help, and 
accessed VBAXL10.CHM. I found a method called AutoFit. 

===
#Format workbook columns
worksheet.range("b1:b4").Interior['ColorIndex'] = 36 #pale yellow
worksheet.range("b:b").AutoFit
===

However, because I was originally working with a CSV file, the above approach 
doesn't quite work. It requires changing the code to something like:

===
#open spreadsheet
excel = WIN32OLE::new('excel.Application')
workbook = excel.Workbooks.Add
worksheet = workbook.Worksheets(1)
worksheet.SaveAs("spreadsheet.xls")

#Log results
worksheet.range("a1").value = executionEnvironment
worksheet.range("b1").value = "Acceptable Screen1 time"
worksheet.range("c1").value = acceptableScreen1.to_s
worksheet.range("d1").value = "Actual Screen1 time"
worksheet.range("e1").value = actualScreen1.to_s
worksheet.range("f1").value = resultValue
#
# Etcetera...assume the above happens 4 times, for 4 screens...
#
#Format workbook columns
worksheet.range("b1:b4").Interior['ColorIndex'] = 36 #pale yellow
worksheet.columns("b:b").AutoFit
#close the workbook
workbook.save
workbook.close
excel.Quit
===

Now this code will work just fine, AS LONG AS the file "spreadsheet.xls" 
actually exists as an Excel file. This is why the "Add" is done for workbooks, 
and then the "SaveAs" is done for the worksheet -- up front!!!! This way, the 
file is created and saved as an Excel spreadsheet. Thus when later the 
formatting is needed -- it works!
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=4494&messageID=12553#12553
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to