PHPackages                             aman.maurya/office-exporter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. aman.maurya/office-exporter

ActiveLibrary

aman.maurya/office-exporter
===========================

This library will generate document file such as MsWord and OpenDoc

014PHP

Since Aug 10Pushed 5y agoCompare

[ Source](https://github.com/aman-maurya/OfficeExporter)[ Packagist](https://packagist.org/packages/aman.maurya/office-exporter)[ RSS](/packages/amanmaurya-office-exporter/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

OfficeExporter
==============

[](#officeexporter)

This library will generate document file such as MsWord and OpenDoc

### Installation

[](#installation)

To install library, simply:

```
$ composer require aman.maurya/office-exporter @dev

```

### Requirements

[](#requirements)

php: &gt;=5.6.40

### Getting Started

[](#getting-started)

- First you have to create template in word processor (Microsoft Office 2007 and above) with extension \[.docx\].
- Then extract the main content file from word processor template. This can be done using php script or manually, [here](https://github.com/aman-maurya/OfficeExporter#step-to-extract-main-content-file-from-word-processor-template) in this example I have chosen manual process.
- Convert the XML file to [XSLT stylesheet](https://www.w3schools.com/xml/xsl_intro.asp).

```

		....

```

- Generate XML form database result.

###### Basic

[](#basic)

```
require __DIR__ . 'vendor/autoload.php';

use OfficeExporter\Xml;

$xml = new Xml('employee');

$xml->setData('row', [
	'name' => 'Vivian Warner',
	'empId' => '123',
]);

$xml->setData('row', [
	'name' => 'Shane Lloyd',
	'empId' => '456',
]);

$xml->generateXml();

		Vivian Warner
		123

		Shane Lloyd
		456

```

###### Advance

[](#advance)

```
require __DIR__ . 'vendor/autoload.php';

use OfficeExporter\Xml;

$xml = new Xml('employee');

$xml->setData('row.name:vivian|age:13|address:123 street', [
	'name' => 'Vivian Warner',
	'empId.department:Engg' => '123',
]);

$xml->setData('row.name:vivian|age:30|address:456 street', [
	'names' => [
		['name' => 'person 1'],
		['phones' => [
			['phone' => '9023XXXXXXXX'],
			['phone' => '9223XXXXXXXX']
		]],
	],
	'empId.department:IT' => '456',
]);

$xml->generateXml();

        Vivian Warner
        123

            person 1

                9023XXXXXXXX

                9223XXXXXXXX

        456

```

- Merge the XmL and XSLT to generate a new ZIP archive.

```
$download->setDocTemplate('sample_word.docx');
$download->setXsltSource('document.xslt');
```

### Step to extract main content file from word processor template

[](#step-to-extract-main-content-file-from-word-processor-template)

- Create the word file with template.
- Change that word file from .docx to .zip, and then extract that zip file.
- Go inside the extracted folder and find the folder with name word.
- Enter inside that folder and copy document.xml file and paste it at any location outside the extract folder and delete all extracted files.
- Now convert document.xml file to XSLT stylesheet
- Change it back word.zip file to word.docx file.

 [![Office Exporter in action](https://github.com/aman-maurya/OfficeExporter/raw/master/OfficeExporter.gif)](https://github.com/aman-maurya/OfficeExporter/blob/master/OfficeExporter.gif)

### Quick Start and Examples

[](#quick-start-and-examples)

```
require __DIR__ . 'vendor/autoload.php';

use OfficeExporter\Xml;
use OfficeExporter\MsWord;

$xml = new Xml('employee');

$xml->setData('row', [
	'name' => 'Vivian Warner',
	'empId' => '123',
]);

$xml->setData('row', [
	'name' => 'Shane Lloyd',
	'empId' => '456',
]);

$xml->generateXml();

$xmlString = $xml->__toString();

$download = new MsWord($xmlString);
$download->setDocTemplate('sample_word.docx');
$download->setXsltSource('document.xslt');
$download->create('sample.docx');
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/98ce8fd98272d09129771d819bbe90d0a80552a2effe003949da09846972b193?d=identicon)[aman-maurya](/maintainers/aman-maurya)

---

Top Contributors

[![aman-maurya](https://avatars.githubusercontent.com/u/20361924?v=4)](https://github.com/aman-maurya "aman-maurya (2 commits)")

---

Tags

msofficemswordoffice-toolsopendocphpphp-libraryrft

### Embed Badge

![Health badge](/badges/amanmaurya-office-exporter/health.svg)

```
[![Health](https://phpackages.com/badges/amanmaurya-office-exporter/health.svg)](https://phpackages.com/packages/amanmaurya-office-exporter)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
