使用 ruby mpxj 读取 asta/power 项目文件时出现以下错误
/var/lib/gems/2.3.0/gems/mpxj-5.2.2/lib/mpxj/reader.rb:24:in `read': Failed to read file: Reading input file started. (RuntimeError)
java.lang.UnsupportedOperationException
at net.sf.mpxj.asta.AstaFileReader.readDatabaseFile(AstaFileReader.java:126)
at net.sf.mpxj.asta.AstaFileReader.read(AstaFileReader.java:74)
at net.sf.mpxj.reader.AbstractProjectReader.read(AbstractProjectReader.java:49)
at net.sf.mpxj.sample.MpxjConvert.process(MpxjConvert.java:81)
at net.sf.mpxj.sample.MpxjConvert.main(MpxjConvert.java:56)
from test.rb:3:in `<main>'
红宝石文件看起来像:
require 'mpxj'
project = MPXJ::Reader.read("asta.pp")
puts "There are #{project.all_tasks.size} tasks in this project"
puts "There are #{project.all_resources.size} resources in this project"
puts "The resources are:"
project.all_resources.each do |resource|
puts resource.name
end
puts "The tasks are:"
project.all_tasks.each do |task|
puts "#{task.name}: starts on #{task.start}, finishes on #{task.finish}, it's duration is #{task.duration}"
end
不知道为什么会出现这个错误,因为我可以在 Asta Project Viewer 中查看程序,所以文件不能损坏。