summaryrefslogtreecommitdiffhomepage
path: root/examples/conditional_formatting/stop_and_go.rb
diff options
context:
space:
mode:
authorZsolt Kozaroczy <[email protected]>2020-09-11 00:36:29 +0200
committerGitHub <[email protected]>2020-09-11 00:36:29 +0200
commit282eec44ef01746ee25931fa6cd287ad083fd40b (patch)
tree14504bf429ca264812679ca971c1592853d3f762 /examples/conditional_formatting/stop_and_go.rb
parent317e8244e4d17c394c1e181f86df3974623fb865 (diff)
downloadcaxlsx-282eec44ef01746ee25931fa6cd287ad083fd40b.tar.gz
caxlsx-282eec44ef01746ee25931fa6cd287ad083fd40b.zip
Restructure examples folder (#47)
Split examples into separate markdown files, each containing a description, sample code, and a screenshot of the resulting xlsx document. The script `generate.rb` is provided to actually generate the example documents by executing the sample code contained in the markdown files.
Diffstat (limited to 'examples/conditional_formatting/stop_and_go.rb')
-rw-r--r--examples/conditional_formatting/stop_and_go.rb37
1 files changed, 0 insertions, 37 deletions
diff --git a/examples/conditional_formatting/stop_and_go.rb b/examples/conditional_formatting/stop_and_go.rb
deleted file mode 100644
index 301bf3fa..00000000
--- a/examples/conditional_formatting/stop_and_go.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env ruby -w -s
-# -*- coding: utf-8 -*-
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
-require 'axlsx'
-p = Axlsx::Package.new
-p.workbook do |wb|
- # define your regular styles
- styles = wb.styles
- title = styles.add_style :sz => 15, :b => true, :u => true
- default = styles.add_style :border => Axlsx::STYLE_THIN_BORDER
- header = styles.add_style :bg_color => '00', :fg_color => 'FF', :b => true
- money = styles.add_style :format_code => '#,###,##0', :border => Axlsx::STYLE_THIN_BORDER
- percent = styles.add_style :num_fmt => Axlsx::NUM_FMT_PERCENT, :border => Axlsx::STYLE_THIN_BORDER
-
- # define the style for conditional formatting - its the :dxf bit that counts!
- profitable = styles.add_style :fg_color => 'FF428751', :sz => 12, :type => :dxf, :b => true
-
- wb.add_worksheet(:name => 'Downtown traffic') do |ws|
- ws.add_row ['A$$le Q1 Revenue Historical Analysis (USD)'], :style => title
- ws.add_row
- ws.add_row ['Quarter', 'Profit', '% of Total'], :style => header
- ws.add_row ['Q1-2010', '15680000000', '=B4/SUM(B4:B7)'], :style => [default, money, percent]
- ws.add_row ['Q1-2011', '26740000000', '=B5/SUM(B4:B7)'], :style => [default, money, percent]
- ws.add_row ['Q1-2012', '46330000000', '=B6/SUM(B4:B7)'], :style => [default, money, percent]
- ws.add_row ['Q1-2013(est)', '72230000000', '=B7/SUM(B4:B7)'], :style => [default, money, percent]
-
- ws.merge_cells 'A1:C1'
-
- # Apply conditional formatting to range B3:B7 in the worksheet
- icon_set = Axlsx::IconSet.new
- ws.add_conditional_formatting 'B3:B7', { :type => :iconSet,
- :dxfId => profitable,
- :priority => 1,
- :icon_set => icon_set }
- end
-end
-p.serialize 'stop_and_go.xlsx'