{"id":4595,"date":"2024-03-14T12:30:00","date_gmt":"2024-03-14T12:30:00","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=4595"},"modified":"2024-03-14T12:53:21","modified_gmt":"2024-03-14T12:53:21","slug":"phpspreadsheet-basics","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/spreadsheet\/phpspreadsheet\/phpspreadsheet-basics","title":{"rendered":".PhpSpreadsheet basics"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Documentation<\/h4>\n\n\n\n<p><a href=\"https:\/\/phpspreadsheet.readthedocs.io\/en\/latest\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/phpspreadsheet.readthedocs.io\/en\/latest\/<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Using in your PHP file<\/h4>\n\n\n\n<p>Add these to the top of your PHP file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Include for PhpSpreadsheet:\nrequire_once '\/vendor\/autoload.php';\nuse PhpOffice\\PhpSpreadsheet\\Spreadsheet;\nuse PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx;<\/code><\/pre>\n\n\n\n<p>Depending on your server you might need something like this instead:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  require_once $_SERVER&#91;'DOCUMENT_ROOT'] . '\/..\/vendor\/autoload.php';    \/\/In this example the \"vendor\/\" folder is above the sites \"pubic_html\/\" folder<\/code><\/pre>\n\n\n\n<p>You can test it works using their example test code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  $spreadsheet = new Spreadsheet();\n  $activeWorksheet = $spreadsheet-&gt;getActiveSheet();\n  $activeWorksheet-&gt;setCellValue('A1', 'Hello World !');\n\n  $writer = new Xlsx($spreadsheet);\n  $writer-&gt;save('hello world.xlsx');<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Documentation https:\/\/phpspreadsheet.readthedocs.io\/en\/latest\/ Using in your PHP file Add these to the top of your PHP file: Depending on your server you might need something like this instead: You can test it works using their example test code:<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[360],"tags":[],"class_list":["post-4595","post","type-post","status-publish","format-standard","hentry","category-phpspreadsheet"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=4595"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4595\/revisions"}],"predecessor-version":[{"id":4600,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4595\/revisions\/4600"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=4595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=4595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=4595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}