PHPSpreadsheet · Google Sheets API · Excel
Spreadsheets, driven by code.
Hands-on PHP tutorials for working with Excel and Google Sheets — read and
write .xlsx, convert files to JSON, stream downloads in the
browser, and insert images, formulas, and styling. Every guide ships with
code you can copy, run, and adapt.
Latest complete code
<?php require 'vendor/autoload.php'; use \PhpOffice\PhpSpreadsheet\IOFactory; use \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf; // Load the existing Excel file. $spreadsheet = IOFactory::load('data.xlsx'); // Hand the spreadsheet to the Dompdf writer and save it as a PDF. $writer = new Dompdf($spreadsheet); $writer->save('output.pdf'); echo "Done. Converted data.xlsx to output.pdf\n";
The full script from Convert An Excel File To PDF In PHP Using PHPSpreadSheet — copy, run, adapt.
Key methods
IOFactory::load()
PhpSpreadsheet
getActiveSheet()
PhpSpreadsheet
fromArray()
PhpSpreadsheet
getCalculatedValue()
PhpSpreadsheet
save('php://output')
PhpSpreadsheet
spreadsheets_values->get()
Google Sheets
spreadsheets_values->update()
Google Sheets
spreadsheets->create()
Google Sheets
json_encode()
PHP
header()
PHP
Latest articles
Convert An Excel File To PDF In PHP Using PHPSpreadSheet
July 27, 2026
Freeze The Header Row In Excel Files In PHP Using PHPSpreadSheet
July 26, 2026
Create An Excel Chart In PHP Using PHPSpreadSheet
July 25, 2026
Work With Multiple Worksheets In Excel Files In PHP Using PHPSpreadSheet
July 24, 2026
Convert A CSV File To Excel In PHP Using PHPSpreadSheet
July 23, 2026
Read Large Excel Files In Chunks In PHP Using PHPSpreadSheet
July 22, 2026
Read Formula Results In Excel Files In PHP Using PHPSpreadSheet
July 21, 2026
Export MySQL Data To Excel Files In PHP Using PHPSpreadSheet
July 20, 2026
Import Excel Files Into MySQL In PHP Using PHPSpreadSheet
July 19, 2026
Browse by technique