Technically this is a Ruby question but...since it is useful to record test run timing information in Excel format, I think it is relevant to this forum. The question is...suppose I write out some test output that looks like this: === Test, Acceptable log in time, 5, Actual time to log in, 1.683, OK Test, Acceptable admin screen access time, 5, Actual admin screen access time, 3.235, OK Test, Acceptable user search time, 5, Actual user search time, 2.804, OK Test, Acceptable user info time, 5, Actual user info time, 1.923, OK ===
So, it went through 4 screens. The environment is "Test". 2nd column describes acceptable time, 3rd column specifies that time, 4th column states actual time, 5th column is actual time, last column will be OK or NotOK, depending on whether actual exceeds expected. So far, so good. However, I am simply opening and writing out to a CSV file, like so: === timeSpreadsheet.puts executionEnvironment + ",Acceptable user info time," + acceptableTimeDisplayUser.to_s + ",Actual user info time," + (endTime - beginTime).to_s + "," + resultValue === No problems, however, the column widths in the resulting file, when opened by Excel, are the standard 8 character columns. Obviously then, when the file is opened, much of the descriptive text in columns 2 and 4 is hidden. So the question is twofold: (a) Is it possible, when writing to a CSV file, to do so in such a way that when Excel opens the file, it will automatically widen the columns to fit? (I think no.) (b) What then, would be the Excel command, to adjust the column to fit? I can do this: === excel = WIN32OLE::new('excel.Application') workbook = excel.Workbooks.Open("../PC/" + Time.now.strftime("%d-%b-%y") + ".csv") worksheet = workbook.Worksheets(1) #get hold of the first worksheet #Format workbook columns worksheet.range("b1:b4").Interior['ColorIndex'] = 36 #pale yellow # How do I widen the 2nd column? workbook.save workbook.close excel.Quit === So I can open the csv file as an Excel file and make a format change (turn the 2nd column yellow.) But -- I cannot find anywhere, on any forum, or the Ruby online documentation, how to "autofit" the column to the text. And -- no, I do not want to add someones alphaware library if possible, I want to use straight old WIN32OLE. Is this possible????? --------------------------------------------------------------------- Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=4494&messageID=12320#12320 _______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general