All Projects → eightyknots → phpspreadsheet-bundle

eightyknots / phpspreadsheet-bundle

Licence: MIT License
A Symfony bundle to integrate with PHPOffice's PhpSpreadsheet library

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to phpspreadsheet-bundle

Kkfileviewofficeedit
文件在线预览及OFFICE(word,excel,ppt)的在线编辑
Stars: ✭ 234 (+397.87%)
Mutual labels:  excel, office
OfficeExtractor
Extracts embedded OLE objects from Word, Excel, PowerPoint, Open Office and RTF files without needing the original programs
Stars: ✭ 67 (+42.55%)
Mutual labels:  excel, office
Androiddocumentviewer
Android 文档查看: word、excel、ppt、pdf,使用mupdf及tbs
Stars: ✭ 235 (+400%)
Mutual labels:  excel, office
Weihanli.npoi
NPOI Extensions, excel/csv importer/exporter for IEnumerable<T>/DataTable, fluentapi(great flexibility)/attribute configuration
Stars: ✭ 157 (+234.04%)
Mutual labels:  excel, office
excel-to-python-course
Student materials and handouts for Excel to Python course
Stars: ✭ 73 (+55.32%)
Mutual labels:  excel, office
Documentserver
ONLYOFFICE Document Server is an online office suite comprising viewers and editors for texts, spreadsheets and presentations, fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
Stars: ✭ 2,335 (+4868.09%)
Mutual labels:  excel, office
lazyExcel
a simply software like MS-Excel.it can be running muiti-platform...
Stars: ✭ 37 (-21.28%)
Mutual labels:  excel, office
Excelize
Golang library for reading and writing Microsoft Excel™ (XLSX) files.
Stars: ✭ 10,286 (+21785.11%)
Mutual labels:  excel, office
Docs2Pdf
Bulk convert word/powerpoint/excel file to pdf.
Stars: ✭ 27 (-42.55%)
Mutual labels:  excel, office
eec
A fast and lower memory excel write/read tool.一个非POI底层,支持流式处理的高效且超低内存的Excel读写工具
Stars: ✭ 93 (+97.87%)
Mutual labels:  excel, office
Npoi
A .NET library for reading and writing Microsoft Office binary and OOXML file formats.
Stars: ✭ 1,751 (+3625.53%)
Mutual labels:  excel, office
rgpipe
lesspipe for ripgrep for common new filetypes using few dependencies
Stars: ✭ 21 (-55.32%)
Mutual labels:  excel, office
Pylightxl
A light weight, zero dependency, minimal functionality excel read/writer python library
Stars: ✭ 134 (+185.11%)
Mutual labels:  excel, office
Office Ribbonx Editor
An overhauled fork of the original Custom UI Editor for Microsoft Office, built with WPF
Stars: ✭ 205 (+336.17%)
Mutual labels:  excel, office
Phpspreadsheet
A pure PHP library for reading and writing spreadsheet files
Stars: ✭ 10,627 (+22510.64%)
Mutual labels:  excel, office
Office365FiddlerExtension
This Fiddler Extension is an Office 365 centric parser to efficiently troubleshoot Office 365 client application connectivity and functionality.
Stars: ✭ 23 (-51.06%)
Mutual labels:  excel, office
Desktopeditors
An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
Stars: ✭ 1,008 (+2044.68%)
Mutual labels:  excel, office
Tablereport
A python library for making table report.
Stars: ✭ 51 (+8.51%)
Mutual labels:  excel, office
hadoopoffice
HadoopOffice - Analyze Office documents using the Hadoop ecosystem (Spark/Flink/Hive)
Stars: ✭ 56 (+19.15%)
Mutual labels:  excel, office
craXcel-cli
Command line application to unlock Microsoft Office password protected files.
Stars: ✭ 44 (-6.38%)
Mutual labels:  excel, office

PhpSpreadsheetBundle

This bundle integrates your Symfony 3/4/5 app with the PHPOffice PhpSpreadsheet productivity library.

Requirements

This bundle requires, in addition to prerequisites of each PHPOffice library:

* PHP 7.2 or higher
* Symfony 4 or higher

Note: Tags older than v1.0.0 (e.g. v0.2.0) are no longer supported due to deprecated status for both PHP <= 7.1 and Symfony <= 4.4.

Installation

Use composer to require the latest stable version.

$ composer require yectep/phpspreadsheet-bundle

If you're not using Flex, enable the bundle in your AppKernel.php or bundles.php file.

$bundles = array(
    [...]
    new Yectep\PhpSpreadsheetBundle\PhpSpreadsheetBundle(),
);

Usage

This bundle enables the phpoffice.spreadsheet service.

See also the official PHPOffice PhpSpreadsheet documentation.

createSpreadsheet()

Creates an empty \PhpOffice\PhpSpreadsheet\Spreadsheet object, or, if an optional $filename is passed, instantiates the \PhpOffice\PhpSpreadsheet\IOFactory to automatically detect and use the appropriate IWriter class to read the file.

// In your controller
$newSpreadsheet = $this->get('phpoffice.spreadsheet')->createSpreadsheet();
$existingXlsx   = $this->get('phpoffice.spreadsheet')->createSpreadsheet('/path/to/file.xlsx');

createReader(string $type)

Returns an instance of the \PhpOffice\PhpSpreadsheet\Reader class of the given $type.

Types are case sensitive. Supported types are:

  • Xlsx: Excel 2007
  • Xls: Excel 5/BIFF (95)
  • Xml: Excel 2003 XML
  • Slk: Symbolic Link (SYLK)
  • Ods: Open/Libre Office (ODS)
  • Csv: CSV
  • Html: HTML
$readerXlsx  = $this->get('phpoffice.spreadsheet')->createReader('Xlsx');
$spreadsheet = $readerXlsx->load('/path/to/file.xlsx');

createWriter(Spreadsheet $spreadsheet, string $type)

Given a \PhpOffice\PhpSpreadsheet\Spreadsheet object and a writer $type, returns an instance of a \PhpOffice\PhpSpreadsheet\Writer class for that type.

In addition the the read types above, these types are additionally supported for writing, if the appropriate PHP libraries are installed.

  • Tcpdf
  • Mpdf
  • Dompdf
$spreadsheet = $this->get('phpoffice.spreadsheet')->createSpreadsheet();
$spreadsheet->getActiveSheet()->setCellValue('A1', 'Hello world');

$writerXlsx = $this->get('phpoffice.spreadsheet')->createWriter($spreadsheet, 'Xlsx');
$writerXlsx->save('/path/to/destination.xlsx');

Roadmap and Contributions

Contributions are more than welcome. Fork the project, and submit a PR when you're done.

Remaining todos include:

  • Tests and test coverage
  • TravisCI
  • Improved documentation

Symfony serializer

If you are migrating from Symfony Serializer component + CSV encoder - you can use code like

$spreadsheet = $this->get('phpoffice.spreadsheet')->createSpreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle($this->filterVars['wareCategory']->getTitle());
$columnsMap = [];
$lineIndex = 2;
foreach ($data as $line) {
   foreach ($line as $columnName=>$columnValue) {
       if (is_int($columnIndex = array_search($columnName, $columnsMap))) {
           $columnIndex++;
       } else {
           $columnsMap[] = $columnName;
           $columnIndex = count($columnsMap);
       }
       $sheet->getCellByColumnAndRow($columnIndex, $lineIndex)->setValue($columnValue);
   }
   $lineIndex++;
}
foreach ($columnsMap as $columnMapId=>$columnTitle) {
   $sheet->getCellByColumnAndRow($columnMapId+1, 1)->setValue($columnTitle);
}
$writer = $this->get('phpoffice.spreadsheet')->createWriter($spreadsheet, 'Xlsx');
ob_start();
$writer->save('php://output');
$excelOutput = ob_get_clean();

return new Response(
   $excelOutput,
   200,
   [
       'content-type'        =>  'text/x-csv; charset=windows-1251',
       'Content-Disposition' => 'attachment; filename="price.xlsx"'
   ]
);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].