ribojhin / excelmacro
Edit an Excel file that contains macros
Requires
- php: >=7.4.26
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^0.5.0
- php-coveralls/php-coveralls: ^2.2.0
- phpmd/phpmd: @stable
- phpunit/phpunit: ^8.4.3
- slevomat/coding-standard: ^5.0
- squizlabs/php_codesniffer: ^3.5.2
README
This PHP library allows you to modify an Excel file that contains macros without disabling them. For most PHP projects, the library (https://github.com/PHPOffice/PhpSpreadsheet) allows you to manipulate Excel files. However, when you modify an Excel file with macro (xlsm), the macros no longer work. This PHP library will allow you to modify XLSM files without disabling macros. The library only applies to Excel files with macros
Requirements
Installation
You can use Composer or simply Download the Release
Composer
The preferred method is via composer. Follow the installation instructions if you do not already have composer installed.
Once composer is installed, execute the following command in your project root to install this library:
composer require ribojhin/excelmacro
Finally, be sure to include the autoloader:
<?php require_once '/path/to/your-project/vendor/autoload.php';
Quickstart
The example below will load data into an excel file that contains macros:
<?php require_once 'autoload.php'; // Comment this line if you use Composer to install the package use \Ribojhin\Excelmacro; $excelMacro = new Excelmacro("_FILE_PATH_SRC_XLSM_"); // Set excel file path you want to edit $excelMacro->setSheet(0); // Set sheet by index $excelMacro->setCellValue($excelMacro->getSheet(), "_KEY_", '_VALUE_'); // Set cell $excelMacro->save("_FILE_PATH_DEST_XLSM_"); // Set destination file path