From d3cf7bca5728b166c7643ad839efeba60ed0e256 Mon Sep 17 00:00:00 2001 From: Tobias Egli Date: Wed, 2 Feb 2022 16:00:32 +0100 Subject: 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 --- test/workbook/worksheet/tc_cell.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index 04f6bed3..bdbfd59d 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -44,7 +44,7 @@ class TestCell < Test::Unit::TestCase end def test_wide_r - assert_equal(@cAA.r, "AA2", "calculate cell reference") + assert_equal(@cAA.r, "AA2", "calculate cell reference") end def test_r_abs @@ -64,6 +64,18 @@ class TestCell < Test::Unit::TestCase assert_in_delta(6.6, @c.autowidth, 0.01) end + def test_autowidth_with_bold_font_multiplier + style = @c.row.worksheet.workbook.styles.add_style(b: true) + @c.row.worksheet.workbook.bold_font_multiplier = 1.05 + @c.style = style + assert_in_delta(6.93, @c.autowidth, 0.01) + end + + def test_autowidth_with_font_scale_divisor + @c.row.worksheet.workbook.font_scale_divisor = 11.0 + assert_in_delta(6.0, @c.autowidth, 0.01) + end + def test_time @c.type = :time now = DateTime.now -- cgit v1.2.3