{"id":14966047,"url":"https://github.com/raku-community-modules/Spreadsheet-XLSX","last_synced_at":"2025-10-25T13:31:04.031Z","repository":{"id":55015008,"uuid":"263392153","full_name":"raku-community-modules/Spreadsheet-XLSX","owner":"raku-community-modules","description":"Work with Excel (XLSX) spreadsheets in Raku","archived":false,"fork":false,"pushed_at":"2024-11-30T15:18:34.000Z","size":215,"stargazers_count":16,"open_issues_count":3,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-26T00:51:16.591Z","etag":null,"topics":["excel","raku"],"latest_commit_sha":null,"homepage":"https://raku.land/zef:raku-community-modules/Spreadsheet::XLSX","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raku-community-modules.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","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":"2020-05-12T16:31:39.000Z","updated_at":"2024-11-30T19:26:24.000Z","dependencies_parsed_at":"2024-09-14T01:22:19.756Z","dependency_job_id":"865b6821-34b6-47e9-9ef6-bec6e4c6a4ad","html_url":"https://github.com/raku-community-modules/Spreadsheet-XLSX","commit_stats":{"total_commits":68,"total_committers":6,"mean_commits":"11.333333333333334","dds":0.2941176470588235,"last_synced_commit":"1e5e1b86474d9634b21a0ed56f6e77798c5330fc"},"previous_names":["raku-community-modules/spreadsheet-xlsx"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FSpreadsheet-XLSX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FSpreadsheet-XLSX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FSpreadsheet-XLSX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FSpreadsheet-XLSX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raku-community-modules","download_url":"https://codeload.github.com/raku-community-modules/Spreadsheet-XLSX/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238147581,"owners_count":19424287,"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","raku"],"created_at":"2024-09-24T13:35:45.102Z","updated_at":"2025-10-25T13:31:03.671Z","avatar_url":"https://github.com/raku-community-modules.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Actions Status](https://github.com/raku-community-modules/Spreadsheet-XLSX/actions/workflows/linux.yml/badge.svg)](https://github.com/raku-community-modules/Spreadsheet-XLSX/actions)\n\nNAME\n====\n\nSpreadsheet::XLSX - blah blah blah\n\nDESCRIPTION\n===========\n\nA Raku module for working with Excel spreadsheets (XLSX format), both reading existing files, creating new files, or modifying existing files and saving the changes. Of note, it:\n\n  * Knows how to lazily load sheet content, so if you don't look at a sheet then time won't be spent deserializing it (down to a cell level, even)\n\n  * In the modification scenario, tries to leave as much intact as it can, meaning that it's possible to poke data into a sheet more complex than could be produced by the module from scratch\n\n  * Only depends on the Raku `LibXML` and `Libarchive` modules (and their respective native dependencies)\n\nThis module is currently in development, and supports the subset of XLSX format features that were immediately needed for the use-case it was built for. That isn't so much, for now, but it will handle the most common needs:\n\n  * Enumerating worksheets\n\n  * Reading text and numbers from cells on a worksheet\n\n  * Creating new workbooks with worksheets with text and number cells\n\n  * Setting basic styles and number formats on cells in newly created worksheets\n\n  * Reading a workbook, making modifications, and saving it again\n\n  * Reading and writing column properties (such as column width)\n\nSYNOPSIS\n========\n\nReading existing workbooks\n--------------------------\n\n```raku\nuse Spreadsheet::XLSX;\n\n# Read a workbook from an existing file (can pass IO::Path or a\n# Blob in the case it was uploaded).\nmy $workbook = Spreadsheet::XLSX.load('accounts.xlsx');\n\n# Get worksheets.\nsay \"Workbook has {$workbook.worksheets.elems} sheets\";\n\n# Get the name of a worksheet.\nsay $workbook.worksheets.name;\n\n# Get cell values (indexing is zero-based, done as a multi-dimensional array\n# indexing operation [row ; column].\nmy $cells = $workbook.worksheets[0].cells;\nsay .value with $cells[0;0];      # A1\nsay .value with $cells[0;1];      # B1\nsay .value with $cells[1;0];      # A2\nsay .value with $cells[1;1];      # B2\n```\n\nCreating new workbooks\n----------------------\n\n```raku\nuse Spreadsheet::XLSX;\n\n# Create a new workbook and add some worksheets to it.\nmy $workbook = Spreadsheet::XLSX.new;\nmy $sheet-a = $workbook.create-worksheet('Ingredients');\nmy $sheet-b = $workbook.create-worksheet('Matching Drinks');\n\n# Put some data into a worksheet and style it. This is how the model\n# actually works (useful if you want to add styles later).\n$sheet-a.cells[0;0] = Spreadsheet::XLSX::Cell::Text.new(value =\u003e 'Ingredient');\n$sheet-a.cells[0;0].style.bold = True;\n$sheet-a.cells[0;1] = Spreadsheet::XLSX::Cell::Text.new(value =\u003e 'Quantity');\n$sheet-a.cells[0;1].style.bold = True;\n$sheet-a.cells[1;0] = Spreadsheet::XLSX::Cell::Text.new(value =\u003e 'Eggs');\n$sheet-a.cells[1;1] = Spreadsheet::XLSX::Cell::Number.new(value =\u003e 6);\n$sheet-a.cells[1;1].style.number-format = '#,###';\n\n# However, there is a convenience form too.\n$sheet-a.set(0, 0, 'Ingredient', :bold);\n$sheet-a.set(0, 1, 'Quantity', :bold);\n$sheet-a.set(1, 0, 'Eggs');\n$sheet-a.set(1, 1, 6, :number-format('#,###'));\n\n# Save it to a file (string or IO::Path name).\n$workbook.save(\"foo.xlsx\");\n\n# Or get it as a blob, e.g. for a HTTP response.\nmy $blob = $workbook.to-blob();\n```\n\nClass / Method reference\n========================\n\nclass Spreadsheet::XLSX\n-----------------------\n\nThe actual outward facing class\n\n### has Hash $!archive\n\nMap of files in the decompressed archive we read from, if any.\n\n### has Spreadsheet::XLSX::ContentTypes $.content-types\n\nThe content types of the workbook.\n\n### has Associative[Spreadsheet::XLSX::Relationships] %!relationships\n\nMap of loaded relationships for paths. (Those never used are not in here.)\n\nclass Attribute+{\u003canon|2\u003e}.new(handles =\u003e $(\"create-worksheet\", \"worksheets\", \"shared-strings\", \"styles\"))\n----------------------------------------------------------------------------------------------------------\n\nThe workbook itself.\n\n### has Spreadsheet::XLSX::DocProps::Core $!core-props\n\nDocument Core Properties\n\n### multi method load\n\n```raku\nmulti method load(\n    Str $file\n) returns Spreadsheet::XLSX\n```\n\nLoad an Excel workbook from the file path identified by the given string.\n\n### multi method load\n\n```raku\nmulti method load(\n    IO::Path $file\n) returns Spreadsheet::XLSX\n```\n\nLoad an Excel workbook in the specified file.\n\n### multi method load\n\n```raku\nmulti method load(\n    Blob $content\n) returns Spreadsheet::XLSX\n```\n\nLoad an Excel workbook from the specified blob. This is useful in the case it was sent over the network, and so never written to disk.\n\n### method find-relationships\n\n```raku\nmethod find-relationships(\n    Str $path,\n    Bool :$create = Bool::False\n) returns Spreadsheet::XLSX::Relationships\n```\n\nGet the relationships for a given path in the XLSX archive.\n\n### method get-file-from-archive\n\n```raku\nmethod get-file-from-archive(\n    Str $path\n) returns Blob\n```\n\nObtain a file from the archive. Will fail if we are not backed by an archive, or if there is no such file.\n\n### method set-file-in-archive\n\n```raku\nmethod set-file-in-archive(\n    Str $path,\n    Blob $content\n) returns Nil\n```\n\nSet the content of a file in the archive, replacing any existing content.\n\n### method to-blob\n\n```raku\nmethod to-blob() returns Blob\n```\n\nSerializes the current state of the spreadsheet into XLSX format and returns a Blob containing it.\n\n### multi method save\n\n```raku\nmulti method save(\n    Str $file\n) returns Nil\n```\n\nSaves the Excel workbook to the file path identified by the given string.\n\n### multi method save\n\n```raku\nmulti method save(\n    IO::Path $file\n) returns Nil\n```\n\nSave an Excel workbook to the specified file.\n\n### method sync-to-archive\n\n```raku\nmethod sync-to-archive() returns Nil\n```\n\nSynchronizes all changes to the internal representation of the archive. This is performed automatically before saving, and there is no need to explicitly perform it.\n\nCREDITS\n=======\n\nThanks goes to [Agrammon](https://agrammon.ch/) for making the development of this module possible.\n\nAUTHOR\n======\n\nJonathan Worthington\n\nCOPYRIGHT AND LICENSE\n=====================\n\nCopyright 2020 - 2024 Jonathan Worthington\n\nCopyright 2024 Raku Community\n\nThis library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraku-community-modules%2FSpreadsheet-XLSX","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraku-community-modules%2FSpreadsheet-XLSX","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraku-community-modules%2FSpreadsheet-XLSX/lists"}