diff options
| author | Zsolt Kozaroczy <[email protected]> | 2020-09-11 00:36:29 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-11 00:36:29 +0200 |
| commit | 282eec44ef01746ee25931fa6cd287ad083fd40b (patch) | |
| tree | 14504bf429ca264812679ca971c1592853d3f762 /examples/style_overrides_example.md | |
| parent | 317e8244e4d17c394c1e181f86df3974623fb865 (diff) | |
| download | caxlsx-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/style_overrides_example.md')
| -rw-r--r-- | examples/style_overrides_example.md | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/style_overrides_example.md b/examples/style_overrides_example.md new file mode 100644 index 00000000..731ce2e7 --- /dev/null +++ b/examples/style_overrides_example.md @@ -0,0 +1,37 @@ +## Description + +Some of the style attributes can also be set at the cell level. These cell level styles take precedence over custom styles shown in other examples. Use with caution, it could override more styles than you set (see text color in example). + +## Code + +```ruby +require 'axlsx' + +p = Axlsx::Package.new +wb = p.workbook +s = wb.styles + +default_style = s.add_style fg_color: 'FF0000', bg_color: '00FF00' + +wb.add_worksheet(name: 'Style overrides') do |sheet| + sheet.add_row ['Underline', 'Size', 'Bold', 'Italic', 'Outline', 'Color', 'Original'], style: [default_style] * 7 + + sheet.rows.last.tap do |row| + row.cells[0].u = :double + row.cells[1].sz = 20 + row.cells[2].b = true + row.cells[3].i = true + row.cells[4].outline = 1 + row.cells[5].color = '0000FF' # Inline style uses this instead of fg_color + end + + # Could be used on cell range too + sheet['A1:C1'].each { |cell| cell.strike = true } +end + +p.serialize 'style_overrides_example.xlsx' +``` + +## Output + + |
