I've written before about using Ruby with Microsoft's ADO technology to query Excel workbooks as databases.
This works well---most of the time. But you may occasionally bump into data type issues, where you find that Excel/ADO treat a specific column as a different data type than you expected.
For this reason, I recommend using a collection of ADO functions that will expressly convert a value to a specific data type. These ADO functions include:
CStr(x) - Converts x to a String value
CDec(x) - Converts x to a Decimal value
CInt(x) - Converts x to an Integer value
CDate(x) - Converts x to a Date value
CCur(x) - Converts x to a Currency value
For example, instead of assuming that the ORDER_NUMBER field would be treated as a string...
SELECT * FROM ORDERS WHERE ORDER_NUMBER = '12345' ;
...call the CStr() function on it to ensure a string-to-string comparison:
SELECT * FROM ORDERS WHERE CStr(ORDER_NUMBER) = '12345' ;
It's a few extra keystrokes that could save you time---and frustration---in the long run.
More information can be found here.
Saturday, March 3, 2012
ADO, Excel, and Data Types
Posted by David Mullet at 8:00 AM 1 comments
Friday, September 2, 2011
Automating Outlook with Ruby: Saving Mail Messages To Files
I've talked in the past about managing mail messages in your Inbox, and about saving email attachments to your hard drive. A reader recently asked about saving a mail message as a file on your hard drive.
require 'win32ole'olHTML = 5outlook = WIN32OLE.connect("Outlook.Application")mapi = outlook.GetNameSpace("MAPI")inbox = mapi.GetDefaultFolder(6)msg = inbox.Items(2)msg.SaveAs('c:\temp\message.htm', olHTML)
Posted by David Mullet at 7:27 PM 2 comments
Wednesday, March 16, 2011
JRuby 1.6: Now With Win32OLE Goodness
JRuby 1.6 has just been released and, among the many new features, the JRuby installer for Windows now includes the win32ole library.
Posted by David Mullet at 7:01 AM 10 comments
Monday, February 7, 2011
Ruby on NetBeans: Here Comes the Cavalry
As recently reported, the NetBeans IDE team has decided to drop support for Ruby (and Rails) from NetBeans 7.0.
I have received many good suggestions from readers, with RedCar and RubyMine getting a lot of love.
But wait! What's that? It sounds like trumpets off in the distance... and hoofbeats.
Indeed, Tom Enebo is leading the cavalry to save the day, as he reported in the JRuby forum recently:
I have been talking to Netbeans team about us adopting the project and this is a done deal. Putting together some details and you should see a blog post about this in the next few days. So, if you like using Netbeans dont worry, it will still be an available option in the plugins catalog (not sure about the full Ruby product as an independent download from netbeans site yet).Good news for all those that would like to continue to use NetBeans with Ruby.
Thanks, Tom!
Posted by David Mullet at 8:49 AM 3 comments
Thursday, January 27, 2011
NetBeans Drops Support for Ruby and Rails
The NetBeans team has, unfortunately, decided to remove Ruby and Rails support from the NetBeans IDE:
After thorough consideration, we have taken the difficult step to discontinue support for Ruby on Rails in the NetBeans IDE.
As of January 27, the Ruby on Rails module will be gone from development builds of NetBeans IDE 7.0.
Posted by David Mullet at 8:27 AM 13 comments
Labels: tools
Sunday, September 26, 2010
Coming Soon: win32ole for JRuby
FYI: In a recent Ruby Forum thread, Charles Nutter wrote:
FWIW, a win32ole library is in development and should be in JRuby for 1.6.
This is good news for those of us who do a lot of work with the standard Ruby win32ole library.
My sincere thanks to all who are helping to make this happen.
Posted by David Mullet at 5:48 PM 1 comments
Saturday, August 28, 2010
New Ruby IDE Discussion Group
FYI, Ed Howland has launched a new Ruby IDE discussion group:
I set this group up to focus discussions about a community developed IDE written in Ruby (but not necessarily limited to writing code in just that language. The intent is to take general discussion specific off-line from the main ruby-talk group Hopefully, this will be a high signal-noise ratio discussion.
So if you've got some constructive thoughts on what would be the ideal Ruby IDE, make yourself heard here:
http://groups.google.com/group/ruby-ide
David
Posted by David Mullet at 2:03 PM 0 comments