### Install SimpleXLSXGen via Composer Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Install the library using Composer. This is the recommended method for managing dependencies. ```bash $ composer require shuchkin/simplexlsxgen ``` -------------------------------- ### Create Empty Book with Title Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Use SimpleXLSXGen::create() to initialize an empty XLSX workbook with an optional title. This is useful for starting a new spreadsheet. ```php SimpleXLSXGen::create($title = null) ``` -------------------------------- ### Debug: Generate Simple Excel File Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md A basic example to generate a simple Excel file with debug data. Ensure error reporting and display are enabled for debugging purposes. ```php ini_set('error_reporting', E_ALL ); ini_set('display_errors', 1 ); $data = [ ['Debug', 123] ]; Shuchkin\SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx'); ``` -------------------------------- ### Alternative Interface: Get XLSX Content Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Obtain the XLSX content as a string using an alternative interface. This is useful for storing or transmitting the Excel data. ```php $xlsx_cache = (string) (new Shuchkin\SimpleXLSXGen)->addSheet( $books, 'Modern style'); ``` -------------------------------- ### Add AutoFilter Range Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Use the autoFilter method to apply an auto-filter to a specified range of cells. The range is defined by the start and end columns. ```php $xlsx->autoFilter('A2:B10'); ``` -------------------------------- ### Add Namespace Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Introduces namespace support with `use Shuchkin\SimpleXLSXGen;` for better code organization. ```php namespace added, use Shuchkin\SimpleXLSXGen; ``` -------------------------------- ### Classic Interface: Multiple Sheets and Download Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Utilize the classic interface to add multiple sheets to an Excel workbook and then download it. Ensure to include the necessary 'use' statement. ```php use Shuchkin\SimpleXLSXGen; $xlsx = new SimpleXLSXGen(); $xlsx->addSheet( $books, 'Catalog 2021' ); $xlsx->addSheet( $books2, 'Stephen King catalog'); $xlsx->downloadAs('books_2021.xlsx'); exit(); ``` -------------------------------- ### Create Empty Book with Title and Save Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Create an Excel file with a specified title and add sheets to it. The file will be saved with the title as its name. ```php $xlsx = SimpleXLSX::create('My books'); $xlsx->addSheet( $books ); $xlsx->save(); // ./My books.xlsx ``` -------------------------------- ### Use Namespace Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Import the SimpleXLSXGen class into your project using the namespace declaration. This is required for using the library's functionalities. ```php use Shuchkin\SimpleXLSXGen; ``` -------------------------------- ### Hyperlinks to Local Files Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Enables the creation of hyperlinks that point to local files on the user's system. ```php 1.4.11 (2024-02-07) ``` -------------------------------- ### Fluid Interface: Multiple Sheets Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Create an Excel file with multiple sheets using the fluid interface. Specify the data and sheet name for each sheet. ```php Shuchkin\SimpleXLSXGen::fromArray( $books, 'My books' )->addSheet( $books2 )->download(); ``` -------------------------------- ### Multiple Sheets Creation in PHP Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Illustrates how to create Excel workbooks containing multiple sheets using either the fluid interface with addSheet() or the classic interface by instantiating the class and adding sheets sequentially. This is useful for organizing related data. ```php SUM(\'Q1 Sales\'!B2:D3)'], ['Q2', 'SUM(\'Q2 Sales\'!B2:D3)'] ]; // Method 1: Fluid interface SimpleXLSXGen::fromArray($salesQ1, 'Q1 Sales') ->addSheet($salesQ2, 'Q2 Sales') ->addSheet($summary, 'Summary') ->saveAs('quarterly_report.xlsx'); // Method 2: Classic interface $xlsx = new \Shuchkin\SimpleXLSXGen(); $xlsx->addSheet($salesQ1, 'Q1 Sales'); $xlsx->addSheet($salesQ2, 'Q2 Sales'); $xlsx->addSheet($summary, 'Summary'); $xlsx->saveAs('quarterly_report.xlsx'); // Output: Excel workbook with three sheets ?> ``` -------------------------------- ### Cell Alignment and Text Wrapping in PHP Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Demonstrates how to control horizontal and vertical cell alignment and enable text wrapping using specific tags within cell content. Ensure the library is included via 'use Shuchkin\SimpleXLSXGen;'. ```php Left Aligned'], ['Center Align', '
Centered
'], ['Right Align', 'Right Aligned'], ['Top Align', ''], ['Middle Align', ''], ['Bottom Align', ''], ['Center + Middle', ''], ['Word Wrap', 'This is a very long text that will wrap to multiple lines within the cell'], ['Line Breaks', "Line 1\nLine 2\nLine 3"], ['Rotation 90°', 'Rotated Text'] ]; SimpleXLSXGen::fromArray($data) ->setColWidth(1, 20) ->setColWidth(2, 40) ->saveAs('alignment.xlsx'); // Output: Excel file demonstrating various alignment options ?> ``` -------------------------------- ### Add Metadata Methods Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Implements methods for setting various document metadata properties such as title, subject, author, and keywords. ```php 1.3.15 (2023-04-19) ``` -------------------------------- ### Fluid Interface: Download to Browser Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Use the fluid interface to directly download an Excel file to the browser. Requires the array of data and the desired filename. ```php Shuchkin\SimpleXLSXGen::fromArray( $books )->downloadAs('table.xlsx'); ``` -------------------------------- ### Cell Styling with Colors, Backgrounds, and Borders Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Apply cell styling including text color, background color, borders, font size, number formats, and row heights using the `'], ['Red Bold', ''], ['Yellow Background', ''], ['Blue on Yellow', ''], ['Large Font', ''], ['Thin Border', ''], ['Medium Red Border', ''], ['Custom Borders', ''], ['Row Height 50', ''], ['Custom Number Format', ''], ['Currency GBP', ''] ]; // Border styles: none, thin, medium, dashed, dotted, thick, double, hair, // mediumDashed, dashDot, mediumDashDot, dashDotDot, mediumDashDotDot, slantDashDot SimpleXLSXGen::fromArray($data)->saveAs('styles.xlsx'); // Output: Excel file with various cell styles applied ``` -------------------------------- ### Hyperlinks and Internal Links in PHP Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Shows how to create various types of hyperlinks, including external URLs, email addresses, and internal sheet references. The library automatically detects URLs and emails, but explicit tags can be used for styling and specific link types. ```php Visit Example'], ['URL with hash', 'https://en.wikipedia.org/wiki/XLSX#Overview'], ['Styled link', 'Bold Link'], ['Mailto link', 'Email Support'], ['Internal link', 'Go to Sheet 2'], ['Relative file', 'Open other file'], ['File with sheet', 'Link to cell in other file'] ]; $sheet2 = [ ['Welcome to Sheet 2'], ['Back to Sheet 1'] ]; SimpleXLSXGen::fromArray($sheet1, 'Sheet1') ->addSheet($sheet2, 'Sheet2') ->saveAs('hyperlinks.xlsx'); // Output: Excel file with clickable links between sheets and external URLs ?> ``` -------------------------------- ### Static Helper Methods for Data Handling Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Utility methods for date conversion to Excel serial numbers, escaping special XML characters, marking values as raw strings to disable type detection, and converting entire arrays to raw strings. Also includes creating an empty workbook with a title. ```php 10'); // "Values: <5 & >10" // Mark value as raw string (disable type detection) $rawValue = SimpleXLSXGen::raw('+1234567890'); // Convert entire array to raw strings $rawArray = SimpleXLSXGen::rawArray([ ['2024-01-01', '+123', '007'], ['2024-02-01', '+456', '008'] ]); // Create empty workbook with title $xlsx = SimpleXLSXGen::create('My Report'); $xlsx->addSheet([['Data', 'Here']]); $xlsx->save(); // Saves as "My Report.xlsx" ``` -------------------------------- ### Adding Hyperlinks to Excel Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Demonstrates how to add various types of hyperlinks, including internal sheet links, external URLs, mailto links, and relative paths, to an Excel file. ```php $xlsx = SimpleXLSX::fromArray([ ['internal link', 'Go to second sheet'], ['http', 'https://example.com/'], // autodetect ['http + hash', 'https://en.wikipedia.org/wiki/Office_Open_XML#References'], // autodetect ['external anchor', 'Open XML'], ['relative link', 'books'], ['relative link + cell addr', 'link to second sheet in other book'], ['mailto', 'info@example.com'], // autodetect ['mailto 2', 'Please email me'], ])->addSheet([['Second sheet']], 'My books 2')->saveAs('hyperlinks.xlsx'); ``` -------------------------------- ### Handle Various Data Types in XLSX Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Demonstrates how to format different data types including numbers, currencies, dates, and hyperlinks within an XLSX file. Use UTF-8 encoded strings for best results. ```php $data = [ ['Integer', 123], ['Float', 12.35], ['Percent', '12%'], ['Currency $', '$500.67'], ['Currency €', '200 €'], ['Currency ₽', '1200.30 ₽'], ['Currency (other)', ''], ['Currency Float (other)', ''], ['Datetime', '2020-05-20 02:38:00'], ['Date', '2020-05-20'], ['Time', '02:38:00'], ['Datetime PHP', new DateTime('2021-02-06 21:07:00')], ['String', 'Very long UTF-8 string in autoresized column'], ['Formula', 'SUM(B1:B2)'], ['Hyperlink', 'https://github.com/shuchkin/simplexlsxgen'], ['Hyperlink + Anchor', 'SimpleXLSXGen'], ['Internal link', 'Go to second page'], ['RAW string', "\0" . '2020-10-04 16:02:00'], ['Formatted RAW string', '2024-07-28 16:02:00'], ]; SimpleXLSXGen::fromArray($data)->saveAs('datatypes.xlsx'); ``` -------------------------------- ### Add Raw Tag for Styled Values Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Introduces the `` tag for handling raw values with associated styling. ```php 1.4.12 (2024-07-28) ``` -------------------------------- ### Handle RAW Strings (Disable Type Detection) Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Prevent automatic type detection for values that should remain as literal strings. Use the null character prefix, raw() method, or `` tag. ```php
+12345 preserved
'], ['Special chars', SimpleXLSXGen::raw('Values: <5 and >10')] ]; SimpleXLSXGen::fromArray($data)->saveAs('raw_strings.xlsx'); // Convert entire array to raw strings $mixedData = [ ['Date', 'Phone', 'Code'], ['2024-01-15', '+1-555-0123', '007'] ]; $rawData = SimpleXLSXGen::rawArray($mixedData); SimpleXLSXGen::fromArray($rawData)->saveAs('all_raw.xlsx'); // Output: Excel files with values preserved as literal text ``` -------------------------------- ### Set Custom Column Widths Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Set specific column widths for better data presentation. Column indices are 1-based. ```php
ID
', '', ''], [1, 'Product A', 'A detailed description of Product A with multiple features and benefits'], [2, 'Product B', 'Another product with extensive documentation and usage examples'], [3, 'Product C', 'Third product entry with comprehensive feature list'] ]; SimpleXLSXGen::fromArray($data) ->setColWidth(1, 8) // Column A (ID) - narrow ->setColWidth(2, 20) // Column B (Name) - medium ->setColWidth(3, 50) // Column C (Description) - wide ->saveAs('column_widths.xlsx'); // Output: Excel file with custom column widths ``` -------------------------------- ### Freeze Panes for Headers Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Keep headers visible while scrolling by freezing rows and/or columns. Use 'A2' to freeze the first row, 'B1' to freeze the first column, and 'B2' to freeze both. ```php freezePanes('A2') // Freeze top row (headers) ->autoFilter('A1:E1') ->saveAs('freeze_top_row.xlsx'); // Freeze first column SimpleXLSXGen::fromArray($data) ->freezePanes('B1') // Freeze column A ->saveAs('freeze_first_column.xlsx'); // Freeze both first row and first column SimpleXLSXGen::fromArray($data) ->freezePanes('B2') // Freeze row 1 and column A ->saveAs('freeze_both.xlsx'); // Output: Excel files with frozen panes for easier navigation ``` -------------------------------- ### Add Raw Array Method Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Includes the `::rawArray()` method for handling raw array data. ```php 1.5.11 (2025-08-09) ``` -------------------------------- ### Apply Cell Formatting with HTML-like Tags Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Use HTML-like tags within cell data to apply formatting such as bold, italic, underline, hyperlinks, and custom styles including color, font size, and borders. Ensure correct tag nesting for combined effects. ```php $data = [ ['Normal', '12345.67'], ['Bold', '12345.67'], ['Italic', '12345.67'], ['Underline', '12345.67'], ['Strike', '12345.67'], ['Bold + Italic', '12345.67'], ['Hyperlink', 'https://github.com/shuchkin/simplexlsxgen'], ['Italic + Hyperlink + Anchor', 'SimpleXLSXGen'], ['Green', ''], ['Bold Red Text', ''], ['Size 32 Font', ''], ['Blue Text and Yellow Fill', ''], ['Border color', ''], ['Border style',''], ['Border sides', ''], ['Left', '12345.67'], ['Center', '
12345.67
'], ['Right', 'Right Text'], ['Center + Bold', '
Name
'], ['Row height', ''], ['Top', ''], ['Middle + Center', ''], ['Bottom + Right', ''], ['
MERGE CELLS MERGE CELLS MERGE CELLS MERGE CELLS MERGE CELLS
', null], ['Word wrap', "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book"], ['Linebreaks', "Line 1\nLine 2\nLine 3"], ['Comments', 'No Author'], ['Comments + author + linebreaks', "Pushkin"], ['Rotation 90', 'Rotated header'] ]; SimpleXLSXGen::fromArray($data) ->setDefaultFont('Courier New') ->setDefaultFontSize(14) ->setColWidth(1, 35) ->mergeCells('A20:B20') ->saveAs('styles_and_tags.xlsx'); ``` -------------------------------- ### Simple Linebreaks Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Introduces support for simple linebreaks within cell content. ```php 1.3.18 (2023-12-02) ``` -------------------------------- ### Handle Raw Strings to Prevent Type Conversion Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Use the null byte prefix '\0' or the `::raw()` method to ensure data is treated as a string, preventing unintended conversions of numbers, dates, or special characters. The `::rawArray()` method applies this to entire arrays. ```php $PushkinDOB = '1799-07-06'; $data = [ ['Datetime as raw string', "\0" . '2023-01-09 11:16:34'], ['Date as raw string', "\0" . $PushkinDOB], ['Disable type detection', "\0" . '+12345'], ['Method ::raw, insert greater/less them simbols', SimpleXLSXGen::raw('20- short term: <6 month')], ['Formatted raw', '
+123456 <tag>
'], ]; SimpleXLSXGen::fromArray($data) ->saveAs('test_rawstrings.xlsx'); ``` ```php $data = [ ['test', 'raw', 'array'], ['2025-08-09 14:36:34', '< tag >', 1] ]; $raw_data = SimpleXLSXGen::rawArray($data); SimpleXLSXGen::fromArray($raw_data)->saveAs('test_raw_array.xlsx'); ``` -------------------------------- ### Add Custom Date Formats Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Supports custom date formats through the 'nf' attribute, allowing for flexible date representation. ```php 1.4.15 (2025-05-28) ``` -------------------------------- ### Fix Save Methods Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Corrects issues with saveAs, downloadAs, and similar methods that were causing problems when called more than once. ```php 1.0.21 (2021-07-29) ``` -------------------------------- ### Text Formatting with HTML-like Tags Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Apply text formatting such as bold, italic, underline, and strikethrough using simple HTML-like tags within cell content. Combinations of tags are also supported. ```php Bold Text'], ['Italic', 'Italic Text'], ['Underline', 'Underlined Text'], ['Strikethrough', 'Strikethrough Text'], ['Combined', 'Bold Italic Underline'], ['Hyperlink with style', 'Click Here'] ]; SimpleXLSXGen::fromArray($data)->saveAs('formatting.xlsx'); // Output: Excel file with styled text in each cell ``` -------------------------------- ### AJAX Download to Excel Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Handle AJAX requests to convert JavaScript arrays to downloadable Excel files. This server-side script processes POST data and triggers a file download in the browser. ```php downloadAs('export.xlsx'); exit; } ?> Export to Excel ``` -------------------------------- ### Set Document Meta Data Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Set various metadata properties for the Excel document, such as author, company, title, subject, and keywords. ```php $xlsx->setAuthor('John Doe ') ->setCompany('JD LLC ') ->setManager('Jane Doe ') ->setLastModifiedBy("John Doe ") ->setTitle('My Books') ->setSubject('My bookshelf') ->setKeywords('Tolkien,Rowling,Kipling') ->setDescription('Cool books worn by time') ->setCategory('Books') ->setLanguage('en-US') ->setApplication('Shuchkin\SimpleXLSXGen') ``` -------------------------------- ### Generate XLSX from Array Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Use this snippet to create an XLSX file from a PHP array. The generated file can be saved locally or downloaded directly. ```php $books = [ ['ISBN', 'title', 'author', 'publisher', 'ctry' ], [618260307, 'The Hobbit', 'J. R. R. Tolkien', 'Houghton Mifflin', 'USA'], [908606664, 'Slinky Malinki', 'Lynley Dodd', 'Mallinson Rendel', 'NZ'] ]; $xlsx = Shuchkin\SimpleXLSXGen::fromArray( $books ); $xlsx->saveAs('books.xlsx'); // or downloadAs('books.xlsx') or $xlsx_content = (string) $xlsx ``` -------------------------------- ### Add Borders to Cells Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Apply borders to cells using the style tag with the 'border' attribute. Various border styles are supported. ```php ``` -------------------------------- ### Add Cell Colors Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Apply custom text and background colors to cells using the style tag with 'color' and 'bgcolor' attributes. Colors are specified in hexadecimal format. ```php ``` -------------------------------- ### Merge Cells in PHP Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Demonstrates how to merge cells into a single cell using the mergeCells() method with Excel-style range notation (e.g., 'A1:D1'). This is useful for creating headers or spanning labels across multiple columns. Ensure the library is included via 'use Shuchkin\SimpleXLSXGen;'. ```php Sales Report 2024', null, null, null], ['Region', 'Q1', 'Q2', 'Total'], ['North', 1500, 1800, 'SUM(B3:C3)'], ['South', 1200, 1400, 'SUM(B4:C4)'], ['East', 900, 1100, 'SUM(B5:C5)'], ['West', 1100, 1300, 'SUM(B6:C6)'], ['Grand Total:', null, null, 'SUM(D3:D6)'] ]; SimpleXLSXGen::fromArray($data) ->mergeCells('A1:D1') // Merge header across all columns ->mergeCells('A7:C7') // Merge "Grand Total" label ->setColWidth(1, 15) ->saveAs('merged_cells.xlsx'); // Output: Excel file with merged header and footer cells ?> ``` -------------------------------- ### Add Internal Links Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Create internal hyperlinks within the spreadsheet using the 'a' tag, specifying the target sheet and cell. ```php Go to page 2 ``` -------------------------------- ### Fix Empty Cells and Selection Issue Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Resolves an issue related to empty cells and selection problems within the spreadsheet. ```php 1.4.14 (2025-03-07) ``` -------------------------------- ### Set Document Metadata Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Set document properties like author, title, subject, keywords, and other metadata for the Excel file. This is useful for organizing and identifying generated reports. ```php setTitle('Q1 2024 Sales Report') ->setSubject('Quarterly Sales Data') ->setAuthor('John Doe ') ->setCompany('Acme Corporation') ->setManager('Jane Smith') ->setKeywords('sales, quarterly, 2024, widgets') ->setDescription('Comprehensive sales data for Q1 2024') ->setCategory('Reports') ->setLanguage('en-US') ->setApplication('Sales Reporting System v2.0') ->setLastModifiedBy('John Doe') ->saveAs('sales_report.xlsx'); // Output: Excel file with metadata visible in File > Properties ``` -------------------------------- ### Configure Default Font Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Set the default font family and size for the entire workbook. This allows for consistent styling across all cells, with options to override for specific cells using inline styles. ```php Header 1', 'Header 2', 'Header 3'], ['Data row 1', 'Value A', 'Value B'], ['Data row 2', 'Value C', 'Value D'], ['Custom size', '', ''] ]; SimpleXLSXGen::fromArray($data) ->setDefaultFont('Arial') ->setDefaultFontSize(12) ->saveAs('custom_font.xlsx'); // Using different fonts SimpleXLSXGen::fromArray($data) ->setDefaultFont('Courier New') ->setDefaultFontSize(10) ->saveAs('monospace_font.xlsx'); // Output: Excel files with specified default fonts ``` -------------------------------- ### Freeze Panes for Scrolling Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Use the freezePanes method to keep a specified area of the worksheet visible while scrolling. The corner_cell parameter defines the boundary. ```php freezePanes( corner_cell ) ``` -------------------------------- ### Save XLSX to Current Folder Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Use SimpleXLSXGen::save() to save the generated XLSX file in the current directory. The filename can be specified by the book's title or defaults to the current date. ```php SimpleXLSXGen::save() ``` -------------------------------- ### Set Font Size in Cells Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Apply custom font sizes to cell content using the style tag with the 'font-size' attribute. ```php ``` -------------------------------- ### Add AutoFilter to Headers Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Enable dropdown filters on column headers for easy data manipulation. Specify the range of cells to apply the filter to. ```php Name', 'Department', 'Salary', 'Start Date'], ['John Smith', 'Engineering', '$75000', '2020-03-15'], ['Jane Doe', 'Marketing', '$65000', '2019-07-22'], ['Bob Wilson', 'Engineering', '$80000', '2018-11-01'], ['Alice Brown', 'Sales', '$70000', '2021-02-28'], ['Charlie Davis', 'Marketing', '$62000', '2022-01-10'] ]; SimpleXLSXGen::fromArray($data) ->autoFilter('A1:D6') // Enable filter dropdowns on header row ->saveAs('employees_filtered.xlsx'); // Output: Excel file with filter dropdowns on each column header ``` -------------------------------- ### Add Mailto Hyperlink Support in PHP Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Use this snippet to add mailto hyperlinks to your Excel files. Ensure the HTML `` tag is correctly formatted within the cell data. ```php SimpleXLSXGen::fromArray([ ['Mailto hyperlink', 'Please email me'] ])->saveAs('test.xlsx'); ``` -------------------------------- ### Fix fpassthru Disabled Issue Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Addresses an issue where `fpassthru` was disabled, potentially affecting file output streams. ```php 1.4.10 (2023-12-31) ``` -------------------------------- ### Add Rotation Tag Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Introduces the `` tag to apply 90-degree text rotation within cells. ```php 1.5.12 (2025-10-24) ``` -------------------------------- ### Freeze Panes Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Freeze rows and columns from the top-left corner up to, but not including, the specified cell. This keeps headers visible when scrolling. ```php $xlsx->freezePanes('B2'); // B1 - freeze first column, A2 - freeze top row ``` -------------------------------- ### Add Currencies to Data Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Include currency symbols directly in the data array for display in cells. Supports multiple currency formats. ```php $data = [ ['$100.23', '2000.00 €', '1200.30 ₽'] ]; ``` -------------------------------- ### Fix Formula and Style Issue Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Corrects an issue where the 'v="value"' attribute was skipped in formula tags, affecting formula rendering and styling. ```php 1.4.13 (2024-10-13) ``` -------------------------------- ### Force Little Endian Numbers in Zip Headers Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Ensures that numbers in zip headers are written in little-endian format, improving compatibility with certain zip utilities. ```php 1.3.20 (2023-12-12) ``` -------------------------------- ### Set Column Width Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Adjust the width of a specific column using the setColWidth method, specifying the column number (1-based) and the desired width in characters. ```php setColWidth(num_col_started_1, size_in_chars) ``` -------------------------------- ### Fix Sheet Name Duplicates Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Addresses a problem with duplicate sheet names, ensuring each sheet has a unique identifier. ```php 1.0.19 (2021-07-28) ``` -------------------------------- ### Set Right-to-Left Mode Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Enable RTL mode for the worksheet using the rightToLeft() method. This affects column ordering and text direction. ```php $xlsx->rightToLeft() ``` -------------------------------- ### Set Row Height Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Customize the height of rows using the style tag with the 'height' attribute, specifying the desired height in pixels. ```php ``` -------------------------------- ### Data Types and Auto-Detection Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Automatically detects and formats various data types including numbers, dates, currencies, percentages, URLs, emails, and formulas. Ensure correct PHP data types or string formats are used for proper detection. ```php SUM(B2:B4)'], ['Long String', 'This is a very long string that will be auto-sized'] ]; SimpleXLSXGen::fromArray($data)->saveAs('datatypes.xlsx'); // Output: Excel file with properly formatted cells for each data type ``` -------------------------------- ### Preserve Leading or Trailing Spaces Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Ensures that leading and trailing spaces in cell content are preserved and not trimmed. ```php 1.3.16 (2023-09-12) ``` -------------------------------- ### Handle Dates Before 1900 Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Ensures correct handling of dates with years prior to 1900 and time-only cells. This addresses issues with date formatting in specific scenarios. ```php 1.0.23 (2022-02-01) ``` -------------------------------- ### AJAX: JavaScript Function to Send Data for Excel Conversion Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md JavaScript function that converts a 2D array into JSON, sends it to a PHP script via AJAX, and handles the downloaded Excel file. ```javascript function array2excel() { var books = [ ["ISBN", "title", "author", "publisher", "ctry"], [618260307, "The Hobbit", "J. R. R. Tolkien", "Houghton Mifflin", "USA"], [908606664, "Slinky Malinki", "Lynley Dodd", "Mallinson Rendel", "NZ"] ]; var json = JSON.stringify(books); var request = new XMLHttpRequest(); request.onload = function () { if (this.status === 200) { var file = new Blob([this.response], {type: this.getResponseHeader('Content-Type')}); var fileURL = URL.createObjectURL(file); var filename = "", m; var disposition = this.getResponseHeader('Content-Disposition'); if (disposition && (m = /"([^"]+)"/.exec(disposition)) !== null) { filename = m[1]; } var a = document.createElement("a"); if (typeof a.download === 'undefined') { window.location = fileURL; } else { a.href = fileURL; a.download = filename; document.body.appendChild(a); a.click(); } } else { alert("Error: " + this.status + " " + this.statusText); } } request.open('POST', "array2excel.php"); request.responseType = "blob"; request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); request.send("array2excel=" + encodeURIComponent(json)); } ``` -------------------------------- ### Add Custom Number Formats Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Apply custom number formats to cells using the style tag with the 'nf' attribute. This allows for precise control over how numbers are displayed. ```php ``` -------------------------------- ### AJAX: PHP Script to Handle Array to Excel Conversion Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md A PHP script that receives JSON-encoded array data via POST and generates an Excel file for download. This is part of an AJAX-driven process. ```php downloadAs('file.xlsx'); return; } ?> ``` -------------------------------- ### Fix Duplicate Sheet Names Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Resolves an issue where sheet names could be duplicated, leading to naming conflicts like 'Page', 'Page (1)', 'Page (2)', etc. ```php 1.0.20 (2021-07-28) ``` -------------------------------- ### Enable Right-to-Left (RTL) Mode Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Enable Right-to-Left mode for the Excel sheet. This affects column order and text direction, suitable for languages that read right-to-left. ```php $xlsx->rightToLeft(); ``` -------------------------------- ### Fix Multiple Selection Error Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Resolves an error message related to actions not working on multiple selections. ```php 1.3.14 (2023-04-18) ``` -------------------------------- ### Add Cell Comments Source: https://context7.com/shuchkin/simplexlsxgen/llms.txt Attach comments to cells that appear on hover. Comments can include author attribution. Use HTML-like syntax within cell data. ```php $1,250,000', 'Verified'], ['Expenses', '$890,000', 'Pending'], ['Profit', '$360,000', 'Final'], ['Notes', 'See comments', 'OK'] ]; SimpleXLSXGen::fromArray($data) ->setAuthor('Report Generator') ->saveAs('comments.xlsx'); // Output: Excel file with comment indicators on cells (yellow triangle in corner) ``` -------------------------------- ### Fix Special Characters in Sheet Names Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Ensures that quotation marks (") and ampersands (&) are correctly handled and escaped within sheet names. ```php 1.0.17 (2021-07-28) ``` -------------------------------- ### Apply Autofilter Source: https://github.com/shuchkin/simplexlsxgen/blob/master/README.md Apply an autofilter to a specified range of cells in the Excel sheet. This allows for easy data filtering. ```php $xlsx->autoFilter('A1:B10'); ``` -------------------------------- ### Add Cell Comments Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Enables the functionality to add comments to cells within the spreadsheet. ```php 1.5.10 (2025-07-08) ``` -------------------------------- ### Add Formulas to Cells Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Embed formulas within cells using the 'f' tag, specifying the formula value and content. This is useful for calculations within the spreadsheet. ```php SUM(B1:B10) ``` -------------------------------- ### Set Vertical Alignment Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Control the vertical alignment of text within cells using tags like 'top', 'middle', or 'bottom'. ```php 12345 ``` -------------------------------- ### Merge Cells Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Combine multiple cells into a single cell using the mergeCells method, specifying the range of cells to merge. ```php $xlsx->mergeCells('A1:C1') ``` -------------------------------- ### Escape Special Characters Source: https://github.com/shuchkin/simplexlsxgen/blob/master/CHANGELOG.md Escapes specific control characters, namely \x00 (null byte) and \x0B (vertical tab), to prevent issues during file processing. ```php 1.0.22 (2021-10-29) ```