Home  >  Q&A  >  body text

ruby解析excel常见问题?

今天做一脚本用来解析excel如下:
require "rubygems"
require 'parseexcel'
xsl_root = /opt/tool/guest.xsl
workbook = Spreadsheet::ParseExcel.parse xsl_root
worksheet = workbook.worksheet(0)
...
当我运行时出现异常:
default formats are encoded in ISO-8859-1
OLE::UnknownFormatError: OLE::UnknownFormatError
于是到网上google了一下,说是什么excel保存的格式不对,要成2003的那种,试了一下:
文件=>另存为=>*.xsl
再运行脚本同样的问题!
这个情况怎么处理呢?有遇到过相似问题的吗?
0人喜欢

PHPzPHPz2713 days ago869

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-21 10:59:07

    If you are on Windows platform, it is recommended to use win32ole
    The relevant code can be found here http://lj6684.iteye.com/blog/1415623

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-21 10:59:07

    You can consider using roo

    reply
    0
  • Cancelreply