Sha256: 0007daf4501f39e1389f43f0feb3f9eeccfe705febe7ecbfeddc8542bddf5437
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
class Birt::Core::RptDesign #design文件路径 attr_accessor :rpt_design_path #报表的名字 attr_accessor :display_name #数据源 attr_accessor :data_sources #数据集 attr_accessor :data_sets #图表 attr_accessor :reports def initialize(rpt_design_path) self.rpt_design_path = rpt_design_path @data_sources, @data_sets = {}, {} @reports = {tables: {}} end def display_name(root=nil) unless @display_name _root = root|| REXML::Document.new(File.read(self.rpt_design_path)).root names = _root.get_elements("/report/text-property[@name='displayName']") @display_name = names[0].text if names end @display_name end #解析文件 def parse_rpt _root = REXML::Document.new(File.read(self.rpt_design_path)).root #报表名称 @display_name = self.display_name(_root) #数据源 _root.each_element(xpath = '/report/data-sources/oda-data-source') do |item| p @data_sources[item.attribute(:name).value] = Birt::Core::DataSource.new(item) end #数据集 _root.each_element(xpath='/report/data-sets/oda-data-set') do |item| @data_sets[item.attribute(:name).value] = Birt::Core::DataSet.new(item) do |data_set| data_set.data_source = @data_sources[item.get_elements("property[@name='dataSource']")[0].text] end end #报表 _root.each_element(xpath='/report/body/table') do |item| @reports[:tables]["#{item.attribute(:id).value}"] = Birt::Core::TableReport.new(item) do |report| report.data_set = @data_sets[item.get_elements("property[@name='dataSet']")[0].text] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
birt-core-0.1.6 | lib/birt/core/rpt_design.rb |
birt-core-0.1.5 | lib/birt/core/rpt_design.rb |