View on GitHub

WriteXLSX

ruby gem for generating XLSX file.

Download this project as a .zip file Download this project as a tar.gz file

CONTENTS

CHART FONTS

The following font properties can be set for any chart object that they apply to (and that are supported by WriteXLSX) such as chart titles, axis labels, axis numbering and data labels. They correspond to the equivalent Worksheet cell Format object properties. See FORMAT METHODS for more information.

:name
:size
:bold
:italic
:underline
:rotation
:color

The following explains the available font properties:

:name

Set the font name:

chart.set_x_axis( num_font: { name: 'Arial' } )
:size

Set the font size:

chart.set_x_axis( num_font: { name: 'Arial', size: 10 } )
:bold

Set the font bold property, should be 0 or 1:

chart.set_x_axis( num_font: { bold: 1 } )
:italic

Set the font italic property, should be 0 or 1:

chart.set_x_axis( num_font: { italic: 1 } )
:underline

Set the font underline property, should be 0 or 1:

chart.set_x_axis( num_font: { underline: 1 } )
:rotation

Set the font rotation in the integer range -90 to 90, and 270-271:

chart.set_x_axis( num_font: { rotation: 45 } )

This is useful for displaying large axis data such as dates in a more compact format.

There are 2 special case angles outside the range -90 to 90:

:color

Set the font color property. Can be a color index, a color name or HTML style RGB colour:

chart.set_x_axis( num_font: { color: 'red' } )
chart.set_y_axis( num_font: { color: '#92D050' } )

Here is an example of Font formatting in a Chart program:

# Format the chart title.
chart.set_title(
    name:      'Sales Results Chart',
    name_font: {
        name:  'Calibri',
        color: 'yellow',
    }
)

# Format the X-axis.
chart.set_x_axis(
    name:      'Month',
    name_font: {
        name:  'Arial',
        color: '#92D050'
    },
    num_font: {
        name:  'Courier New',
        color: '#00B0F0',
    }
)

# Format the Y-axis.
chart.set_y_axis(
    name:      'Sales (1000 units)',
    name_font: {
        name:      'Century',
        underline: 1,
        color:     'red'
    },
    num_font: {
        bold:   1,
        italic: 1,
        color:  '#7030A0',
    }
)