I've got a problem when using Shoes. I'm basically trying to open an excel document and pass the names of the worksheets to a list_box. The following method is called on a button press after selecting a file. (This all works and the file opens)
exc = WIN32OLE::new('excel.Application')
excWB = exc.Workbooks.Open(xlsFile)
@excWS = Array::new
exc.visible = true
excWB.Worksheets.each { |ws| @excWS.push(ws.name) }
para @excWS
list_box :items=> @excWS
Not only do the names not show up in the list_box, the app crashes shortly after loading the box with no error. para @excWS shows the nam开发者_如何学Goes of the worksheets with no problem.
What am I doing wrong?
it is the encoding that was the problem This works
Shoes.app :width => 400, :height => 340, :size => 8 do
require 'win32ole'
exc = WIN32OLE::new('excel.Application')
excWB = exc.Workbooks.Open('C:/Shoes/0.r1514/test/book1.xls')
@excWS = Array::new
exc.visible = false
excWB.Worksheets.each { |ws| @excWS.push(ws.name.force_encoding("UTF-8")) }
list_box :items=> @excWS
exc.ActiveWorkbook.Close(0);
exc.Quit();
end
精彩评论