{"id":24326530,"url":"https://github.com/arodiss/xlsbundle","last_synced_at":"2025-08-08T07:19:22.279Z","repository":{"id":11299738,"uuid":"13714632","full_name":"arodiss/XlsBundle","owner":"arodiss","description":"Trivia read and write of .xls files for Symfony2","archived":false,"fork":false,"pushed_at":"2018-09-01T17:06:14.000Z","size":43,"stargazers_count":5,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-27T19:02:24.059Z","etag":null,"topics":["bundle","excel","php","phpexcel","symfony","symfony-bundle","xls","xlsx"],"latest_commit_sha":null,"homepage":null,"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/arodiss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-20T06:22:48.000Z","updated_at":"2019-11-22T19:07:58.000Z","dependencies_parsed_at":"2022-09-16T19:22:58.822Z","dependency_job_id":null,"html_url":"https://github.com/arodiss/XlsBundle","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/arodiss/XlsBundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arodiss%2FXlsBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arodiss%2FXlsBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arodiss%2FXlsBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arodiss%2FXlsBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arodiss","download_url":"https://codeload.github.com/arodiss/XlsBundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arodiss%2FXlsBundle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269381053,"owners_count":24407748,"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","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bundle","excel","php","phpexcel","symfony","symfony-bundle","xls","xlsx"],"created_at":"2025-01-17T21:12:23.397Z","updated_at":"2025-08-08T07:19:22.228Z","avatar_url":"https://github.com/arodiss.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Xls Bundle\n==========\n\nTrivia read and write of .xls files for Symfony2, built on top of the [PHPExcel](https://github.com/PHPOffice/PHPExcel/)\n\nInstallation\n--------\nVia composer:\n```\nrequire: {\n    ...\n    \"arodiss/xls-bundle\": \"*@stable\"\n}\n```\n\nUsage examples:\n--------\n\nRead a small file\n--------\n```PHP\n$reader = $container-\u003eget(\"arodiss.xls.reader\");\n$content = $reader-\u003ereadAll(\"/path/to/file.xls\");\nvar_dump($content);\n//array(2) =\u003e\n//    array(2) =\u003e\n//        0 =\u003e string(10) \"First line\"\n//        1 =\u003e null\n//    array(2) =\u003e\n//        0 =\u003e string(10) \"Line number\"\n//        1 =\u003e int 2\n```\n\nRead a big file\n--------\nPrevious method can exhaust your memory if the file is big. However this is safe:\n```PHP\n$reader = $container-\u003eget(\"arodiss.xls.reader\");\n$iterator = $reader-\u003egetReadIterator(\"/path/to/file.xls\");\nwhile($iterator-\u003evalid())\n{\n    var_dump($iterator-\u003ecurrent());\n    $iterator-\u003enext();\n}\n//same output format\n```\n\nRead even a bigger file\n--------\nSometime PHPOffice just can't provide reasonable performance. For this case bundle provides alternative reader which wraps python implementation.\nIt is rudimentary in terms of functionality and especially interactions (like error handling), but performs faster, especially on large files.\nIn order to use it, you have to install `openpyxl` (for xlsx) and xlrd (for xls) libraries, which you can easily do through [pip](https://pypi.python.org/pypi/pip) package manager\n\n```PHP\n$reader = $container-\u003eget(\"arodiss.xls.reader.python\");\n$iterator = $reader-\u003egetReadIterator(\"/path/to/file.xls\");\nwhile($iterator-\u003evalid())\n{\n    var_dump($iterator-\u003ecurrent());\n    $iterator-\u003enext();\n}\n//same output format\n```\n\nReturn XLS file from Symfony controller\n--------\n```PHP\n$file = $container\n    -\u003eget(\"arodiss.xls.builder\")\n    -\u003ebuildXlsFromArray(array(\n        array(\"row one field one\", \"row one field two\"),\n        array(\"row two field one\")\n    ))\n;\n\n//now $file is path to tmp file with data\n\n$response = new Response();\n$response-\u003eheaders-\u003eset(\"Content-Type\", \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\");\n$response-\u003eheaders-\u003eset(\"Content-Disposition\", \"attachment;filename=excelfile.xlsx\");\n$response-\u003esetContent(file_get_contents($file));\nreturn $response;\n```\n\n\nWrite in a file (recommended)\n--------\n```PHP\n$writer = $container-\u003eget(\"arodiss.xls.writer.buffered\");\n$writer-\u003ecreate(\"users.xls\", array(\"name\", \"email\")); //second argument represents first row\n\nforeach ($userProvider-\u003egetUsers() as $user) {\n    $writer-\u003eappendRow(\"users.xls\", array($user-\u003egetName(), $user-\u003egetEmail()));\n}\n$writer-\u003eflush();\n\n```\n\nWrite in a file (not recommended)\n--------\nWrite operations for xls format are extremely expensive, so previous example uses BufferedWriter which stores your data in buffer and writes in file only once, when flushing the buffer.\nIf for some reason this is not what you want to achieve, you may use service `xls.writer` in stead of `xls.writer.buffered`.\n\nFormats supported\n--------\nFiles are always written in Excel2007 (.xlsx) format. Read operations, however, MAY work also for other formats supported by PHPExcel (Excel5, Office Open XML, SpreadsheetML, OASIS, CSV, Gnumeric, SYLK) however there is no guarantee for it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farodiss%2Fxlsbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farodiss%2Fxlsbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farodiss%2Fxlsbundle/lists"}