Hi All,
I am generating excel report.

Here is my code:
module WriteReport
  require 'spreadsheet'
  require 'rubyXL'
  require 'time'

def self.get_blank_row
 workbook = RubyXL::Parser.parse($result_xl)
 worksheet = workbook['Test']
    my_rows_indx = []
    worksheet.each_with_index { |row, index|
      my_rows_indx << index if row != nil
    }
    return my_rows_indx.last+1
  end

  def self.write_report
    workbook = RubyXL::Parser.parse($result_xl)
    row = get_blank_row.to_i
    worksheet = workbook['Test']

    worksheet.insert_cell(row, 0, $time, formula = nil)
    worksheet.insert_cell(row, 1, $url, formula = nil)
    worksheet.insert_cell(row, 2, $elec_disc, formula = nil)
    worksheet.insert_cell(row, 3, $check_box, formula = nil)
    worksheet.insert_cell(row, 4, $full_disc, formula = nil)
    worksheet.insert_cell(row, 5, $report, formula = nil)
    workbook.write($result_xl)
  end
end

Here I am creating and parsing excel sheet.
# --- getting time for file name
$time = Time.now.strftime('%Y -%m -%d')

# --- initiating excel files
$result_temp = "reports/excel_result.xlsx"
$result_xl = "reports/result/#{$time}_Result.xlsx"

# --- Parsing excel and writing new for result
workbook1 = RubyXL::Parser.parse($result_temp)
workbook1.write($result_xl)

In hooks.rb:
Before('@watir')do
  launch_browser
end

After('@watir') do
  $report = "PASS"
  $report = "FAIL" if scenario.failed?
  WriteReport.write_report
  quit_browser
end
 

Thank You,
Ajay.

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to