I have processed a log file and created a data structure of below format
values = [ {:VM=>"VM_US_OLA_1"}
{:id=>"OLFTB51", :datum=>{"LAP"=>"6.93817", "YCC_OWER"=>"1.0391"}}
{:id=>"OLFTB10", :datum=>{"LAP_2"=>"2.72646", "CFG_ON"=>"15.9489746", "YCC_ON"=>".401794"}}
{:VM=>"VM_ASIA_FLO_1"}
{:id=>"LOPMLAP", :datum=>{"LAP"=>"1.81048584", "FM_ON"=>".00"} ]
values is an array.
I'm trying to create a spreadsheet of below format where only the VM column gets highlighted in green and for every VM set, a blank line highlighted in 'yellow' should be inserted. I tried multiple approaches and went thru the axlsx documentation too but unable to get the desired format.
My excel snippet below:
require 'axlsx'
p = Axlsx::Package.new
p.workbook.add_worksheet(:name => "Statistics") do |sheet|
    style1 = sheet.styles.add_style(:bg_color => "EF0920", :fg_color => "FFFFFF", b:true)
    style2 = sheet.styles.add_style(:bg_color => "00FF00", :fg_color => "FFFFFF", b:true)
    sheet.add_row ["VM", "NAME", "DETAILS", "OCC"], :style => style1
    values.each do |val|
      sheet.add_row [ val[:VM], val[:id] ], :style =>[style2, nil]
      val[:datum].each do |k, v|
        sheet << ["", "",  k, v]        
       end 
         end
    sheet.add_row
end
p.serialize 'Stat.xlsx'
Any suggestions should be really helpful here, many thanks.
Expected Output
Current Output
Adding Log file and my code
Log
        ---- vm name ----
        VM_US_OLA_1
        OLFTB51
        OWNER                   IN_GB
        ------------------------------ ----------
        LAP                    6.93817
        YCC_OWER               1.0391
        =========================================
        ---- vm name ----
        OLFTB10
        OWNER                   IN_GB
        ------------------------------ ----------
        LAP_2                  2.7266846
        CFG_ON                 15.9489746
        YCC_ON                .401794
        =========================================
        ---- vm name ----
        VM_ASIA_FLO_1
        LOPMLAP
        OWNER                   IN_GB
        ------------------------------ ----------
        LAP                1.81048584
        FM_ON              .00
        =========================================
        ---- vm name ----
        INGTY_2
        OWNER                   IN_GB
        ------------------------------ ----------
  =========================================
    so on of the same format
Code to process the logs
require 'csv'
values = []
total = File.read("final.log")
total.each_line do |line|
  line.strip!
  next if line.empty?
  next if line.include?('selected') || line.include?('IN_GB')
  next if ['-','='].include? line[0]
  parts = line.split ' '
   if parts.size == 1 and line.start_with?('size')
    values[current += 1] = {vm: line.strip}
    next
  elsif parts.size == 1 and parts = /^(?!.*size_).*$/
    values[current += 1] = {id: line, datum: {}}
    next
  end
  parts.each_cons(2) do |key, value|
    values[current][:datum][key] = value 
    end
end
puts values


