{"id":13878343,"url":"https://github.com/axlsx-styler-gem/axlsx_styler","last_synced_at":"2025-07-16T14:32:00.498Z","repository":{"id":27164228,"uuid":"30633694","full_name":"axlsx-styler-gem/axlsx_styler","owner":"axlsx-styler-gem","description":"Build clean and maintainable styles for your axlsx spreadsheets. Build your spreadsheeet with data and then apply styles later.","archived":true,"fork":false,"pushed_at":"2022-12-22T21:45:30.000Z","size":133,"stargazers_count":77,"open_issues_count":1,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-17T14:48:55.365Z","etag":null,"topics":["axlsx","ruby","spreadsheet"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axlsx-styler-gem.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-11T06:17:34.000Z","updated_at":"2023-10-17T00:45:46.000Z","dependencies_parsed_at":"2023-01-14T06:08:08.036Z","dependency_job_id":null,"html_url":"https://github.com/axlsx-styler-gem/axlsx_styler","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axlsx-styler-gem%2Faxlsx_styler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axlsx-styler-gem%2Faxlsx_styler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axlsx-styler-gem%2Faxlsx_styler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axlsx-styler-gem%2Faxlsx_styler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axlsx-styler-gem","download_url":"https://codeload.github.com/axlsx-styler-gem/axlsx_styler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226138849,"owners_count":17579496,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["axlsx","ruby","spreadsheet"],"created_at":"2024-08-06T08:01:46.834Z","updated_at":"2024-11-24T07:30:58.081Z","avatar_url":"https://github.com/axlsx-styler-gem.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# axlsx_styler\n\n\u003ca href=\"https://badge.fury.io/rb/axlsx_styler\" target=\"_blank\"\u003e\u003cimg height=\"21\" style='border:0px;height:21px;' border='0' src=\"https://badge.fury.io/rb/axlsx_styler.svg\" alt=\"Gem Version\"\u003e\u003c/a\u003e\n\u003ca href='https://github.com/axlsx-styler-gem/axlsx_styler/actions' target='_blank'\u003e\u003cimg src=\"https://github.com/axlsx-styler-gem/axlsx_styler/workflows/Tests/badge.svg\" style=\"max-width:100%;\" height='21' style='border:0px;height:21px;' border='0' alt=\"CI Status\"\u003e\u003c/a\u003e\n\u003ca href='https://rubygems.org/gems/axlsx_styler' target='_blank'\u003e\u003cimg height='21' style='border:0px;height:21px;' src='https://img.shields.io/gem/dt/axlsx_styler?color=brightgreen\u0026label=Rubygems%20Downloads' border='0' alt='RubyGems Downloads' /\u003e\u003c/a\u003e\n\n\u003e **Note**\n\u003e **This gem has been [merged upstream into caxlsx v3.3.0](https://github.com/caxlsx/caxlsx/blob/master/CHANGELOG.md#v3.3.0). Please remove this gem from your Gemfile when using caxlsx@v3.3.0 and above.**\n\n`axlsx_styler` is a gem that allows you to build clean and maintainable styles for your `axlsx` spreadsheets. Build your spreadsheeet with data and then apply styles later.\n\nWhile [`axlsx`](https://github.com/caxlsx/caxlsx) is an excellent tool to build Excel spreadsheets in Ruby, the sheets styles are only applied immediately as the row is created. This makes it very difficult to style easily and effectively.\n\nTo solve this issue, `axlsx_styler` was born to allow the separation of styles from content within your `axlsx` code. It gives you the ability to fill out a spreadsheet with data and apply styles later. \n\nWorks well in any Rails app or outside of any specific Ruby framework.\n\n# Usage\n\nThis gem provides a DSL that allows you to apply styles or borders to ranges of cells.\n\n## Styles\n\n```ruby\nsheet.add_style 'A1:D10', b: true, sz: 14\n```\n\nThe styles can be overlayed, so that later on you can add another style to cells that already have styles.\n\n```ruby\nsheet.add_style 'A1:D1', bg_color: 'FF0000'\n```\n\nApplying multiple styles as a sequence of Ruby hashes is also possible.\n\n```ruby\nbold     = { b: true }\ncentered = { alignment: { horizontal: :center } }\nsheet.add_style 'A2:D2', bold, centered\n```\n\nApplying a style to multiple ranges at once.\n\n```ruby\nsheet.add_style ['A2:G2', \"A8:G8\", \"A12:G12\"], b: true, sz: 14\n```\n\n## Borders\n\nThe border style is to draw a thin black border on all four edges of the selected cell range.\n\n```ruby\nsheet.add_border 'B2:D5'\n```\n\nYou can easily customize the border styles.\n\n```ruby\nsheet.add_border 'B2:D5', [:bottom, :right]\nsheet.add_border 'B2:D5', { edges: [:bottom, :right], style: :thick, color: 'FF0000' }\n```\n\nApplying border to multiple ranges at once.\n\n```ruby\nsheet.add_border ['A2:G2', \"A8:G8\", \"A12:G12\"]\n```\n\n\n## Example\n\nSuppose we want create the following spreadsheet:\n\n![alt text](./spreadsheet.png \"Sample Spreadsheet\")\n\nYou can apply styles after all data is entered, similar to how you'd create an Excel document by hand.\n\n```ruby\nrequire 'axlsx_styler'\n\naxlsx = Axlsx::Package.new\nworkbook = axlsx.workbook\nworkbook.add_worksheet do |sheet|\n  sheet.add_row\n  sheet.add_row ['', 'Product', 'Category',  'Price']\n  sheet.add_row ['', 'Butter', 'Dairy',      4.99]\n  sheet.add_row ['', 'Bread', 'Baked Goods', 3.45]\n  sheet.add_row ['', 'Broccoli', 'Produce',  2.99]\n  sheet.column_widths 5, 20, 20, 20\n\n  # using AxlsxStyler DSL\n  sheet.add_style 'B2:D2', b: true\n  sheet.add_style 'B2:B5', b: true\n  sheet.add_style 'B2:D2', bg_color: '95AFBA'\n  sheet.add_style 'B3:D5', bg_color: 'E2F89C'\n  sheet.add_style 'D3:D5', alignment: { horizontal: :left }\n  sheet.add_border 'B2:D5'\n  sheet.add_border 'B3:D3', [:top]\nend\naxlsx.serialize 'grocery.xlsx'\n```\n\nIf you try creating this same spreadsheet using only `axlsx`, you will find this is much more difficult. See this [See this example](./examples/vanilla_axlsx.md)\n\nFor more examples, please see the [examples folder](./examples/)\n\n# Contributing\n\nWe use the `appraisal` gem for testing multiple versions of `axlsx`. Please use the following steps to test using `appraisal`.\n\n1. `bundle exec appraisal install`\n2. `bundle exec appraisal rake test`\n\n# Credits\n\nCreated by Anton Sakovich - @sakovias\n\nMaintained by Weston Ganger - @westonganger - Uses `axlsx_styler` within the gem,  [`spreadsheet_architect`](https://github.com/westonganger/spreadsheet_architect)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxlsx-styler-gem%2Faxlsx_styler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxlsx-styler-gem%2Faxlsx_styler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxlsx-styler-gem%2Faxlsx_styler/lists"}