当我从excel表中获取日期时收到错误

时间:2011-11-11 06:49:59

标签: ruby excel

当我尝试从Excel工作表中获取日期时,我收到以下错误:

 undefined method `length' for #<Date: 2011-11-11 (4911753/2,0,2299161)>
    C:/ruby192/lib/ruby/gems/1.9.1/gems/watir-2.0.3/lib/watir/input_elements.rb:439:
    in `limit_to_maxlength'
    C:/ruby192/lib/ruby/gems/1.9.1/gems/watir-2.0.3/lib/watir/input_elements.rb:412:
    in `type_by_character'
    C:/ruby192/lib/ruby/gems/1.9.1/gems/watir-2.0.3/lib/watir/input_elements.rb:379:
    in `set'
    profile_check.rb:66:in `test_2'
    C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:695:in `run'
    C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:656:in `block (2 levels) in run_test_
    suites'
    C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:650:in `each'
    C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:650:in `block in run_test_suites'
    C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:649:in `each'
    C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:649:in `run_test_suites'
    C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:609:in `run'
    C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:508:in `block in autorun'

如何解决此错误?

1 个答案:

答案 0 :(得分:0)

在Excel工作表中将该列定义为文本,以便它将获取正确的日期作为您的网页格式。 因为excel表具有不同的日期格式。