summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-07-14 12:46:19 +0900
committerRandy Morgan <[email protected]>2012-07-14 12:46:19 +0900
commitfb86d1f56f1ecd683417f1a1cbe2a00faa2904ad (patch)
tree469defdeedc16852bab296c28bf5db9ad7494449
parent05b5ce187db0f04b7c3c7b70263ec8b82ea0e509 (diff)
downloadcaxlsx-fb86d1f56f1ecd683417f1a1cbe2a00faa2904ad.tar.gz
caxlsx-fb86d1f56f1ecd683417f1a1cbe2a00faa2904ad.zip
Add in conditional formatting examples
-rw-r--r--README.md17
-rwxr-xr-xexamples/example.rb64
-rw-r--r--lib/axlsx/version.rb2
3 files changed, 75 insertions, 8 deletions
diff --git a/README.md b/README.md
index d8ac07cb..3c6c7861 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ Axlsx: Office Open XML Spreadsheet Generation
**License**: MIT License
-**Latest Version**: 1.1.7
+**Latest Version**: 1.1.8
**Ruby Version**: 1.8.7, 1.9.2, 1.9.3
@@ -25,7 +25,7 @@ Axlsx: Office Open XML Spreadsheet Generation
**Rubinius Version**: rubinius 2.0.0dev * lower versions may run, this gem always tests against head.
-**Release Date**: June 11th 2012
+**Release Date**: July 14th 2012
If you are working in rails, or with active record see:
http://github.com/randym/acts_as_xlsx
@@ -70,8 +70,6 @@ Feature List
**10. Support for formulas, merging, row and column outlining as well as
cell level input data validation.
-**11. Support for cell merging as well as column and row outline
-
**12. Auto filtering tables with worksheet.auto_filter as well as support for Tables
**13. Export using shared strings or inline strings so we can inter-op with iWork Numbers (sans charts for now).
@@ -82,6 +80,9 @@ cell level input data validation.
**16. Support for password and non password based sheet protection.
+**17. First stage interoperability support for GoogleDocs, LibraOffice,
+and Numbers
+
Installing
----------
@@ -114,13 +115,15 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem,
#Change log
---------
-- **July.??.12**: 1.1.8 release
+- **July.14.12**: 1.1.8 release
+ - added html entity encoding for sheet names. This allows you to use
+ characters like '<' and '&' in your sheet names.
- new - first round google docs interoperability
- added filter to strip out control characters from cell data.
- added in interop requirements so that charts are properly exported
to PDF from Libra Office
- - The beginnings of 'The Great Rename' so that all attributes use
- snake case, and parse to the proper camel case
+ - various readability improvements and work standardizing attribute
+ names to snake_case. Aliases are provided for backward compatiblity
- **June.11.12**: 1.1.7 release
- fix chart rendering issue when label offset is specified as a
percentage in serialization and ensure that formula are not stored
diff --git a/examples/example.rb b/examples/example.rb
index 464b381d..feec1a08 100755
--- a/examples/example.rb
+++ b/examples/example.rb
@@ -356,6 +356,70 @@ wb.add_worksheet(:name => 'fixed headers') do |sheet|
end
end
+# conditional formatting
+#
+percent = wb.styles.add_style(:format_code => "0.00%", :border => Axlsx::STYLE_THIN_BORDER)
+money = wb.styles.add_style(:format_code => '0,000', :border => Axlsx::STYLE_THIN_BORDER)
+
+# define the style for conditional formatting
+profitable = wb.styles.add_style( :fg_color=>"FF428751",
+ :type => :dxf)
+
+wb.add_worksheet(:name => "Conditional Formatting: Cell Is") do |ws|
+
+ # Generate 20 rows of data
+ ws.add_row ["Previous Year Quarterly Profits (JPY)"]
+ ws.add_row ["Quarter", "Profit", "% of Total"]
+ offset = 3
+ rows = 20
+ offset.upto(rows + offset) do |i|
+ ws.add_row ["Q#{i}", 10000*((rows/2-i) * (rows/2-i)), "=100*B#{i}/SUM(B3:B#{rows+offset})"], :style=>[nil, money, percent]
+ end
+
+# Apply conditional formatting to range B3:B100 in the worksheet
+ ws.add_conditional_formatting("B3:B100", { :type => :cellIs, :operator => :greaterThan, :formula => "100000", :dxfId => profitable, :priority => 1 })
+end
+
+wb.add_worksheet(:name => "Conditional Formatting: Color Scale") do |ws|
+ ws.add_row ["Previous Year Quarterly Profits (JPY)"]
+ ws.add_row ["Quarter", "Profit", "% of Total"]
+ offset = 3
+ rows = 20
+ offset.upto(rows + offset) do |i|
+ ws.add_row ["Q#{i}", 10000*((rows/2-i) * (rows/2-i)), "=100*B#{i}/SUM(B3:B#{rows+offset})"], :style=>[nil, money, percent]
+ end
+# Apply conditional formatting to range B3:B100 in the worksheet
+ color_scale = Axlsx::ColorScale.new
+ ws.add_conditional_formatting("B3:B100", { :type => :colorScale, :operator => :greaterThan, :formula => "100000", :dxfId => profitable, :priority => 1, :color_scale => color_scale })
+end
+
+
+wb.add_worksheet(:name => "Conditional Formatting: Data Bar") do |ws|
+ ws.add_row ["Previous Year Quarterly Profits (JPY)"]
+ ws.add_row ["Quarter", "Profit", "% of Total"]
+ offset = 3
+ rows = 20
+ offset.upto(rows + offset) do |i|
+ ws.add_row ["Q#{i}", 10000*((rows/2-i) * (rows/2-i)), "=100*B#{i}/SUM(B3:B#{rows+offset})"], :style=>[nil, money, percent]
+ end
+# Apply conditional formatting to range B3:B100 in the worksheet
+ data_bar = Axlsx::DataBar.new
+ ws.add_conditional_formatting("B3:B100", { :type => :dataBar, :dxfId => profitable, :priority => 1, :data_bar => data_bar })
+end
+
+wb.add_worksheet(:name => "Conditional Formatting: Icon Set") do |ws|
+ ws.add_row ["Previous Year Quarterly Profits (JPY)"]
+ ws.add_row ["Quarter", "Profit", "% of Total"]
+ offset = 3
+ rows = 20
+ offset.upto(rows + offset) do |i|
+ ws.add_row ["Q#{i}", 10000*((rows/2-i) * (rows/2-i)), "=100*B#{i}/SUM(B3:B#{rows+offset})"], :style=>[nil, money, percent]
+ end
+# Apply conditional formatting to range B3:B100 in the worksheet
+ icon_set = Axlsx::IconSet.new
+ ws.add_conditional_formatting("B3:B100", { :type => :iconSet, :dxfId => profitable, :priority => 1, :icon_set => icon_set })
+end
+
##Validate and Serialize
#```ruby
diff --git a/lib/axlsx/version.rb b/lib/axlsx/version.rb
index d33616ba..57456c4e 100644
--- a/lib/axlsx/version.rb
+++ b/lib/axlsx/version.rb
@@ -5,6 +5,6 @@ module Axlsx
# When using bunle exec rake and referencing the gem on github or locally
# it will use the gemspec, which preloads this constant for the gem's version.
# We check to make sure that it has not already been loaded
- VERSION="1.1.7" unless defined? Axlsx::VERSION
+ VERSION="1.1.8" unless defined? Axlsx::VERSION
end