cristian cristian wrote in post #1039540:
> Now Im trying to save the workbook as an excel workbook but it saves the
> file as an CSV. I want a .xlsx
>
> So I did this:
>
> .....
> ensure
>   # Save the workbook and close
>   # filename is 'C:\Ruby\Lab\test.csv'
>
>   excel.activeworkbook.SaveAs(filename.split(".").first+".xlsx")
>   excel.activeworkbook.close(false)
>
>   # Quit Excel
>   excel.quit
> end
>
> This saves the file without problem but I cant open it because the file
> format or the file extension is not valid. How should I save it??
>
> Any suggestions?
>
> Br
> cristian

The SaveAs() method accepts a second argument to specify the file
format.

The value for xlOpenXMLWorkbook (Excel 2007+ .xlsx) is 51.

So simply change your SaveAs code to the following:

   excel.activeworkbook.SaveAs(filename.split(".").first+".xlsx", 51)

David

http://rubyonwindows.blogspot.com
http://rubyonwindows.blogspot.com/search/label/excel

-- 
Posted via http://www.ruby-forum.com/.