summaryrefslogtreecommitdiffhomepage
path: root/examples/column_outlines_example.md
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/column_outlines_example.md
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/column_outlines_example.md')
-rw-r--r--examples/column_outlines_example.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/column_outlines_example.md b/examples/column_outlines_example.md
new file mode 100644
index 00000000..6d402af5
--- /dev/null
+++ b/examples/column_outlines_example.md
@@ -0,0 +1,35 @@
+## Description
+
+If you have a list of data that you want to group and summarize, you can create an outline of up to eight levels. Each inner level, represented by a higher number in the outline symbols, displays detail data for the preceding outer level, represented by a lower number in the outline symbols.
+
+## Code
+
+```ruby
+require 'axlsx'
+
+p = Axlsx::Package.new
+wb = p.workbook
+
+s = wb.styles
+header = s.add_style bg_color: 'ADD8E6'
+summary = s.add_style b: true
+
+wb.add_worksheet(name: 'Column outlines') do |sheet|
+ # Header
+ sheet.add_row ['Name', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Summary'], style: header
+ sheet.add_row ['Alice', 51, 67, 46, 23, 82, '=sum(B2:F2)']
+ sheet.add_row ['Bob', 2, 97, 73, 9, 67, '=sum(B3:F3)']
+
+ sheet.outline_level_columns 1, 5, 1, false # From col 1 to col 5, level 1, open
+end
+
+p.serialize 'column_outlines_example.xlsx'
+```
+
+## Output
+
+![Output](images/column_outlines_example_1.png "Output")
+
+After closing the outline:
+
+![Output](images/column_outlines_example_2.png "Output")