summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTobias Egli <[email protected]>2022-02-02 16:00:32 +0100
committerJosef Šimánek <[email protected]>2022-02-06 00:37:27 +0100
commitd3cf7bca5728b166c7643ad839efeba60ed0e256 (patch)
tree9175590f74a43cd394d22b03da1788eef7a7d2af /examples
parent059c9d38c8860775a260711f78222b69535e6163 (diff)
downloadcaxlsx-d3cf7bca5728b166c7643ad839efeba60ed0e256.tar.gz
caxlsx-d3cf7bca5728b166c7643ad839efeba60ed0e256.zip
Autowidth cell calculation is now configurable
On the workbook you can now configure the font_scale_divisor and the bold_font_multiplier to get better results for the automatic cell width calculationb
Diffstat (limited to 'examples')
-rw-r--r--examples/README.md1
-rw-r--r--examples/fine_tuned_autowidth_example.md37
-rw-r--r--examples/images/fine_tuned_autowidth_example.pngbin0 -> 56940 bytes
3 files changed, 38 insertions, 0 deletions
diff --git a/examples/README.md b/examples/README.md
index a90dc87d..c1335892 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -57,6 +57,7 @@ Customizations:
* [Column widths](column_widths_example.md)
* [Outlines](column_outlines_example.md)
* [No autowidth](no_autowidth_example.md)
+* [Fine tuned autowidth](fine_tuned_autowidth_example.md)
### Filters
diff --git a/examples/fine_tuned_autowidth_example.md b/examples/fine_tuned_autowidth_example.md
new file mode 100644
index 00000000..42b332bc
--- /dev/null
+++ b/examples/fine_tuned_autowidth_example.md
@@ -0,0 +1,37 @@
+## Description
+
+This is an example of how to use font_scale_divisor and bold_font_multiplier to fine-tune the automatic column width calculation.
+
+## Code
+
+```ruby
+require 'axlsx'
+
+p = Axlsx::Package.new
+wb = p.workbook
+wb.font_scale_divisor = 11.5
+wb.bold_font_multiplier = 1.05
+s = wb.styles
+sm_bold = s.add_style b: true, sz: 5
+m_bold = s.add_style b: true, sz: 11
+b_bold = s.add_style b: true, sz: 16
+ub_bold = s.add_style b: true, sz: 21
+sm_text = s.add_style sz: 5
+m_text = s.add_style sz: 11
+b_text = s.add_style sz: 16
+ub_text = s.add_style sz: 21
+
+wb.add_worksheet(name: 'Line Chart') do |sheet|
+ sheet.add_row(['Lorem', 'Lorem', 'Lorem', 'Lorem', 'Lorem', 'Lorem', 'Lorem', 'Lorem', 'WWW', 'www', 'iii', 'iii',
+ 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed',
+ 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed'],
+ style: [sm_bold, m_bold, b_bold, ub_bold, sm_text, m_text, b_text, ub_text,
+ b_bold, b_text, b_bold, b_text, b_bold, b_text])
+end
+
+p.serialize 'fine_tuned_autowidth_example.xlsx'
+```
+
+## Output
+
+![Output](images/fine_tuned_autowidth_example.png "Output") \ No newline at end of file
diff --git a/examples/images/fine_tuned_autowidth_example.png b/examples/images/fine_tuned_autowidth_example.png
new file mode 100644
index 00000000..56f99706
--- /dev/null
+++ b/examples/images/fine_tuned_autowidth_example.png
Binary files differ