diff options
| author | Tobias Egli <[email protected]> | 2022-02-02 16:00:32 +0100 |
|---|---|---|
| committer | Josef Šimánek <[email protected]> | 2022-02-06 00:37:27 +0100 |
| commit | d3cf7bca5728b166c7643ad839efeba60ed0e256 (patch) | |
| tree | 9175590f74a43cd394d22b03da1788eef7a7d2af /lib/axlsx/workbook/workbook.rb | |
| parent | 059c9d38c8860775a260711f78222b69535e6163 (diff) | |
| download | caxlsx-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 'lib/axlsx/workbook/workbook.rb')
| -rw-r--r-- | lib/axlsx/workbook/workbook.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb index 48b7f882..edf719d1 100644 --- a/lib/axlsx/workbook/workbook.rb +++ b/lib/axlsx/workbook/workbook.rb @@ -85,6 +85,9 @@ require 'axlsx/workbook/worksheet/selection.rb' # *workbookPr is only supported to the extend of date1904 class Workbook + BOLD_FONT_MULTIPLIER = 1.5 + FONT_SCALE_DIVISOR = 10.0 + # When true, the Package will be generated with a shared string table. This may be required by some OOXML processors that do not # adhere to the ECMA specification that dictates string may be inline in the sheet. # Using this option will increase the time required to serialize the document as every string in every cell must be analzed and referenced. @@ -213,6 +216,8 @@ require 'axlsx/workbook/worksheet/selection.rb' @use_autowidth = true + @bold_font_multiplier = BOLD_FONT_MULTIPLIER + @font_scale_divisor = FONT_SCALE_DIVISOR self.date1904= !options[:date1904].nil? && options[:date1904] yield self if block_given? @@ -243,6 +248,26 @@ require 'axlsx/workbook/worksheet/selection.rb' # see @use_autowidth def use_autowidth=(v=true) Axlsx::validate_boolean v; @use_autowidth = v; end + # Font size of bold fonts is multiplied with this + # Used for automatic calculation of cell widths with bold text + # @return [Float] + attr_reader :bold_font_multiplier + + def bold_font_multiplier=(v) + Axlsx::validate_float v + @bold_font_multiplier = v + end + + # Font scale is calculated with this value (font_size / font_scale_divisor) + # Used for automatic calculation of cell widths + # @return [Float] + attr_reader :font_scale_divisor + + def font_scale_divisor=(v) + Axlsx::validate_float v + @font_scale_divisor = v + end + # inserts a worksheet into this workbook at the position specified. # It the index specified is out of range, the worksheet will be added to the end of the # worksheets collection |
