{"id":17061576,"url":"https://github.com/paxa/fast_excel","last_synced_at":"2025-04-14T19:46:06.157Z","repository":{"id":17943999,"uuid":"83049367","full_name":"Paxa/fast_excel","owner":"Paxa","description":"Ultra Fast Excel Writer for Ruby","archived":false,"fork":false,"pushed_at":"2025-03-19T11:01:39.000Z","size":1772,"stargazers_count":341,"open_issues_count":34,"forks_count":60,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-07T17:01:39.679Z","etag":null,"topics":["excel","libxlsxwriter","ruby","xlsx"],"latest_commit_sha":null,"homepage":"","language":"C","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/Paxa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-24T14:28:05.000Z","updated_at":"2025-04-04T08:33:36.000Z","dependencies_parsed_at":"2024-06-18T15:28:37.046Z","dependency_job_id":"112be3f9-43d0-4e99-bef4-8a85ae244881","html_url":"https://github.com/Paxa/fast_excel","commit_stats":{"total_commits":122,"total_committers":24,"mean_commits":5.083333333333333,"dds":0.3688524590163934,"last_synced_commit":"b0e62ccf9f9d512137baba1a1b96032b7ff6f457"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Ffast_excel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Ffast_excel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Ffast_excel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Paxa%2Ffast_excel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Paxa","download_url":"https://codeload.github.com/Paxa/fast_excel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248950672,"owners_count":21188314,"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":["excel","libxlsxwriter","ruby","xlsx"],"created_at":"2024-10-14T10:47:32.164Z","updated_at":"2025-04-14T19:46:06.127Z","avatar_url":"https://github.com/Paxa.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ultra Fast Excel Writer for Ruby\n\n```ruby\nrequire 'fast_excel'\n\nworkbook = FastExcel.open(\"hello_world.xlsx\", constant_memory: true)\nworkbook.default_format.set(\n  font_size: 0, # user's default\n  font_family: \"Arial\"\n)\n\nworksheet = workbook.add_worksheet(\"Example Report\")\n\nbold = workbook.bold_format\nworksheet.set_column(0, 0, FastExcel::DEF_COL_WIDTH, bold)\n\nprice = workbook.number_format(\"#,##0.00\")\nworksheet.set_column(1, 1, 20, price)\n\ndate_format = workbook.number_format(\"[$-409]m/d/yy h:mm AM/PM;@\")\nworksheet.set_column(2, 2, 20, date_format)\n\nworksheet.append_row([\"message\", \"price\", \"date\"], bold)\n\nfor i in 1..1000\n  worksheet.append_row([\"Hello\", (rand * 10_000_000).round(2), Time.now])\nend\n\nworksheet.append_row([\"Sum\", FastExcel::Formula.new(\"SUM(B2:B1001)\")], bold)\n\nworkbook.close\n```\n\nSee [more examples](https://github.com/Paxa/fast_excel/tree/master/examples)\n\nThis repository and gem contain sources of [libxlsxwriter](https://github.com/jmcnamara/libxlsxwriter)\n\n## Install\n\n```ruby\n# Gemfile\ngem 'fast_excel'\n```\nOr\n```\ngem install fast_excel\n```\n\n\n\n### Create Document\n```ruby\nworkbook = FastExcel.open # creates tmp file\n# ...\nsend_data(workbook.read_string, filename: \"table.xlsx\") # read tmp file and delete it\n```\n\nAlso can use  `workbook.remove_tmp_folder` to delete tmp file manually\n\n\n**Constant memory mode**: saves each row to disk, good for really big files but can not change previous lines that already saved\n```ruby\nworkbook = FastExcel.open(constant_memory: true)\n```\n\n**Save to file**\n```ruby\nworkbook = FastExcel.open(\"my_dinner.xlsx\")\n```\n\n### Write Data\nFastExcel will automatically detect data type and one of `write_number` or `write_datetime` or `write_formula` or `write_string` or `write_url`\n```ruby\nworkbook = FastExcel.open\nworksheet = workbook.add_worksheet\n\n# write specific type value value\nworksheet.write_number(row = 0, col = 5, 1_234_567, format = nil)\n\n# write value with type detection\nworksheet.write_value(row = 0, col = 5, 1_234_567, format = nil)\n\n# write row of values. format argument can be format object or array of format objects\nworksheet.write_row(row = 1, [\"strong\", 123_456, Time.now], format = nil)\n\n# write row to the bottom\nworksheet.append_row([\"strong\", 123_456, Time.now], )\n\n# shortcut for append_row()\nworksheet \u003c\u003c [\"strong\", 123_456, Time.now]\n```\n\n**Saving dates**: excel store dates as number of days since 1st January 1900, and FastExcel will make it for you.\n\nTo make saving of dates slightly faster can use `FastExcel.date_num` helper:\n```ruby\ndate_format = workbook.number_format(\"[$-409]m/d/yy hh:mm;@\")\nworksheet.write_number(0, 0, FastExcel.date_num(Time.now, Time.zone.utc_offset), date_format)\n```\n\n**Formulas**: special type of value in excel\n```ruby\nworksheet \u003c\u003c [1, 2, 3, 4]\nworksheet \u003c\u003c [FastExcel::Formula.new(\"SUM(A1:D1)\")] # A2 will be shown as 10\n```\n\n**URL**: Link to website or something else\n```ruby\nurl_format = workbook.add_format(underline: :underline_single, font_color: :blue) # format is optional\nworksheet.append_row([\n  FastExcel::URL.new(\"https://github.com/Paxa/fast_excel\"),\n  FastExcel::URL.new(\"postgres://localhost\")\n], url_format)\n# or\nworksheet.write_url(0, 2, \"https://github.com/Paxa/fast_excel\", url_format)\n```\n\n\n### Data Formatting\n```ruby\nformat = workbook.add_format(\n  bold: true,\n  italic: true,\n  font_outline: true,\n  font_shadow: true,\n  text_wrap: true,\n  font_strikeout: true,\n  shrink: true,\n  text_justlast: true,\n  font_size: 13, # default is 11, use 0 for user's default\n  font_name: \"Arial\", # default is Calibri, also accessible via font_family\n  font_color: :orange, # can use RGB hex as \"#FF0000\" or 0x00FF00 or color name as symbol or string\n  font_script: :font_subscript,\n  rotation: 10,\n  underline: :underline_single, # or :underline_double or :underline_single_accounting or :underline_double_accounting\n  indent: 1,\n  # border styles\n  border: :border_thin,\n  left: :medium,\n  top: :dashed,\n  right: :double,\n  bottom: :hair,\n  bottom_color: :alice_blue,\n  top_color: \"#11ABCD\",\n  # Align\n  align: {h: :align_center, v: :align_vertical_center},\n  num_format: \"#,##0.00\"\n)\n```\n\n**Shortcuts**:\n```ruby\nworkbook.bold_format # bold text\nworkbook.number_format(\"[$-409]m/d/yy h:mm AM/PM;@\") # format for date\n```\n\n### Set Column Width\n\n```ruby\nworksheet.set_column(start_col, end_col, width = nil, format = nil)\n# or\nworksheet.set_column_width(col, width = 60)\n# or\nworksheet.set_columns_width(start_col, end_col, width = 60)\n```\n\n### Set Row Height\n```ruby\nworksheet.set_row(row_num = 0, height = 30, format = nil)\n```\n\n### Column Auto Width\n\nColumn authwidth only works for string values, because numbers may have custom formatting\n\nEnabling column auto widths will slow down writing string values for about 15-25%\n\n```ruby\nrequire 'fast_excel'\n\nworkbook = FastExcel.open(constant_memory: true)\n\nworksheet = workbook.add_worksheet\nworksheet.auto_width = true\n\nworksheet.append_row([\"some text\", \"some longer text for example\"])\n\ncontent = workbook.read_string\nFile.open('./some_file.xlsx', 'wb') {|f| f.write(content) }\n```\n\n![fast_excel_auto_width](https://user-images.githubusercontent.com/26019/51788441-ba981300-21b0-11e9-9611-54dda78effcd.png)\n\n\n### API\n\nThis gem is FFI binding for libxlsxwriter C library with some syntax sugar. All original functions is avaliable, for example:\n\n```ruby\nLibxlsxwriter.worksheet_activate(worksheet) # =\u003e will call void worksheet_activate(lxw_worksheet *worksheet)\n# or shorter:\nworksheet.activate\n```\n\nFull libxlsxwriter documentation: [http://libxlsxwriter.github.io/](http://libxlsxwriter.github.io/)\n\nGenerated rdoc: [rubydoc.info/github/Paxa/fast_excel](https://www.rubydoc.info/github/Paxa/fast_excel)\n\n## Benchmarks\n\n1000 rows:\n```\nComparison:\n           FastExcel:       31.7 i/s\n               Axlsx:        8.0 i/s - 3.98x  slower\n          write_xlsx:        6.9 i/s - 4.62x  slower\n```\n\n20000 rows:\n```\nComparison:\n           FastExcel:        1.4 i/s\n               Axlsx:        0.4 i/s - 3.46x  slower\n          write_xlsx:        0.1 i/s - 17.04x  slower\n```\n\nMax memory usage, generating 100k rows:\n```\nFastExcel   - 20 MB\nAxlsx       - 60 MB\nwrite_xlsx - 100 MB\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaxa%2Ffast_excel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaxa%2Ffast_excel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaxa%2Ffast_excel/lists"}