{"id":16798901,"url":"https://github.com/sjelfull/craft3-beam","last_synced_at":"2025-03-15T13:31:06.626Z","repository":{"id":57061887,"uuid":"109170777","full_name":"sjelfull/craft3-beam","owner":"sjelfull","description":"Generate CSVs and XLS files in your templates","archived":false,"fork":false,"pushed_at":"2024-04-24T09:25:35.000Z","size":49,"stargazers_count":17,"open_issues_count":3,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-24T22:19:43.429Z","etag":null,"topics":["craft","craft3","craftcms","craftcms-plugin"],"latest_commit_sha":null,"homepage":"https://superbig.co","language":"PHP","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/sjelfull.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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-11-01T18:53:47.000Z","updated_at":"2024-04-24T09:19:56.000Z","dependencies_parsed_at":"2024-10-13T09:27:19.117Z","dependency_job_id":"d8e81979-a116-4ca1-92f0-70bdea7bed0a","html_url":"https://github.com/sjelfull/craft3-beam","commit_stats":{"total_commits":24,"total_committers":4,"mean_commits":6.0,"dds":0.125,"last_synced_commit":"b42428359e2374bb91517ade710d5d66f88747b0"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjelfull%2Fcraft3-beam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjelfull%2Fcraft3-beam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjelfull%2Fcraft3-beam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjelfull%2Fcraft3-beam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sjelfull","download_url":"https://codeload.github.com/sjelfull/craft3-beam/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243735820,"owners_count":20339535,"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":["craft","craft3","craftcms","craftcms-plugin"],"created_at":"2024-10-13T09:27:14.620Z","updated_at":"2025-03-15T13:31:06.291Z","avatar_url":"https://github.com/sjelfull.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Beam plugin for Craft CMS 3.x\n\nGenerate CSVs and XLS files in your templates\n\n![Screenshot](resources/img/plugin-logo.png)\n\n## Requirements\n\nThis plugin requires Craft CMS 3.0.0-beta.23 or later.\n\n## Installation\n\nTo install the plugin, follow these instructions.\n\n1. Open your terminal and go to your Craft project:\n\n        cd /path/to/project\n\n2. Then tell Composer to load the plugin:\n\n        composer require superbig/craft3-beam\n\n3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Beam.\n\n## Using Beam\n\nThe starting point when working with Beam is to create a instance:\n\n```twig\n{% set options = {\n    header: ['Email', 'Name'],\n    content: [\n        [ 'test@example.com', 'John Doe' ],\n        [ 'another+test@example.com', 'Jane Doe' ],\n        [ 'third+test@example.com', 'Trond Johansen' ],\n    ]\n} %}\n{% set beam = craft.beam.create(options) %}\n```\n\nThis will return a `BeamModel` behind the scenes.\n\nIf you want to append content dynamically, say from a loop, you can use the `append` method:\n\n```twig\n{% set myUserQuery = craft.users()\n    .group('authors') %}\n\n{# Fetch the users #}\n{% set users = myUserQuery.all() %}\n\n{# Display the list #}\n{% for user in users %}\n    {% do beam.append([user.username, user.name, user.email]) %}\n{% endfor %}\n```\n\n### To generate an CSV:\n```twig\n{% do beam.csv() %}\n```\n\n### To generate an XLSX:\n```twig\n{% do beam.xlsx() %}\n```\n\n### Changing config on the fly\n\nTo set the header of the file (the first row):\n```twig\n{% do beam.setHeader([ 'Username', 'Name', 'Email' ]) %}\n``` \n\nTo set the filename:\n```twig\n{% set currentDate = now|date('Y-m-d') %}\n{% do beam.setFilename(\"report-#{currentDate}\") %}\n```\n\nTo overwrite the content:\n```twig\n{% do beam.setContent([\n    [ 'test@example.com', 'John Doe' ],\n    [ 'another+test@example.com', 'Jane Doe' ],\n    [ 'third+test@example.com', 'Trond Johansen' ],\n]) %}\n```\n\n### Custom cell formatting is supported for XLSX:\n\n```twig\n{% set options = {\n    header: ['Email', 'Name', { text: 'Number', type: 'number' }, { text: 'Date', type: 'date' }],\n    content: [\n        [ 'test@example.com', 'John Doe', 100000, '2022-06-10'],\n        [ 'another+test@example.com', 'Jane Doe', 252323, '2022-06-22'],\n        [ 'third+test@example.com', 'Trond Johansen', 30, '2022-06-22'],\n        [ 'third+test@example.com', 'Trond Johansen', 6233, '2023-06-22'],\n    ]\n} %}\n{% set beam = craft.beam.create(options) %}\n{%  do beam.xlsx() %}\n```\n\nThese types are supported:\n\n| Format Type | Maps to the following cell format         |\n|-------------|-------------------------------------------|\n| string      | @                                         |\n| integer     | 0                                         |\n| date        | YYYY-MM-DD                                |\n| datetime    | YYYY-MM-DD HH:MM:SS                       |\n| time        | HH:MM:SS                                  |\n| price       | #,##0.00                                  |\n| dollar      | [$$-1009]#,##0.00;[RED]-[$$-1009]#,##0.00 |\n| euro        | #,##0.00 [$€-407];[RED]-#,##0.00 [$€-407] |\n\nBrought to you by [Superbig](https://superbig.co)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjelfull%2Fcraft3-beam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsjelfull%2Fcraft3-beam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjelfull%2Fcraft3-beam/lists"}