Skip to content

Commit

Permalink
upd: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aVadim483 committed Jan 11, 2025
1 parent a800bd5 commit 046d132
Show file tree
Hide file tree
Showing 41 changed files with 1,045 additions and 24 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This library is designed to be lightweight, super-fast and requires minimal memo
* Supports workbook and sheet protection with/without passwords
* Supports page settings - page margins, page size
* Inserting multiple charts
* Supports data validations
* Supports data validations and conditional formatting

Jump To:
* [Changes in version 6](#changes-in-version-6)
Expand Down Expand Up @@ -393,12 +393,12 @@ and with minimal memory usage.

Benchmark of PhpSpreadsheet (generation without styles)

| Rows x Cols | Time | Memory |
| Rows x Cols | Time | Memory |
|-------------|-----------|------------|
| 1000 x 5 | 0.98 sec | 2,048 Kb |
| 1000 x 25 | 4.68 sec | 14,336 Kb |
| 5000 x 25 | 23.19 sec | 77,824 Kb |
| 10000 x 50 | 105.8 sec | 256,000 Kb |
| 1000 x 5 | 0.98 sec | 2,048 Kb |
| 1000 x 25 | 4.68 sec | 14,336 Kb |
| 5000 x 25 | 23.19 sec | 77,824 Kb |
| 10000 x 50 | 105.8 sec | 256,000 Kb |

Benchmark of FastExcelWriter (generation without styles)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
119 changes: 119 additions & 0 deletions demo/demo-13-conditional-formatting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../src/autoload.php';

$outFileName = __DIR__ . '/output/' . basename(__FILE__, '.php') . '.xlsx';

use avadim\FastExcelWriter\Conditional\Conditional;
use \avadim\FastExcelWriter\Excel;
use avadim\FastExcelWriter\Style;

$timer = microtime(true);

// Create Excel workbook
$excel = Excel::create();

$sheet = $excel->sheet();

$sheet->setColAutoWidth('a');

$sheet->nextRow();
$sheet->writeCell('cell: =5, >5');
$sheet->writeCells(range(0, 9))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::make('=', 5, [Style::FILL_COLOR => '#cfc']))
->applyConditionalFormatting(Conditional::make('>', 5, [Style::FILL_COLOR => '#fcc']))
;

$sheet->nextRow();
$sheet->writeCell('between [3, 6]');
$sheet->writeCells(range(0, 9))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::between([3, 6], [Style::FILL_COLOR => '#ccf']))
;

$sheet->nextRow();
$sheet->writeCell('not between [3, 6]');
$sheet->writeCells(range(0, 9))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::notBetween([3, 6], [Style::FILL_COLOR => '#ccf']))
;

$sheet->nextRow();
$sheet->writeCell('expression: MOD(RC,2)=0');
$sheet->writeCells(range(0, 9))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::expression('MOD(RC,2)=0', [Style::FILL_COLOR => '#ff9']))
;

$sheet->nextRow();
$sheet->writeCell('colorScale');
$sheet->writeCells(range(0, 9))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::colorScale('#f99', 'ff9', '9f9'))
;

$sheet->nextRow();
$sheet->writeCell('dataBar');
$sheet->writeCells(range(0, 9))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::dataBar('#99f'))
;

$sheet->nextRow();
$sheet->writeCell('aboveAverage');
$sheet->writeCells(range(0, 9))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::aboveAverage([Style::FILL_COLOR => '#9f9']))
;

$sheet->nextRow();
$sheet->writeCell('belowAverage');
$sheet->writeCells(range(0, 9))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::belowAverage([Style::FILL_COLOR => '#f99']))
;

$sheet->nextRow();
$sheet->writeCell('uniqueValues');
$sheet->writeCells(array_merge(range(0, 7), [7, 7]))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::uniqueValues([Style::FILL_COLOR => '#99f']))
;

$sheet->nextRow();
$sheet->writeCell('duplicateValues');
$sheet->writeCells(array_merge(range(0, 7), [7, 7]))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::duplicateValues([Style::FILL_COLOR => '#ff9']))
;

$sheet->nextRow();
$sheet->writeCell('top: 3');
$sheet->writeCells(range(0, 9))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::top(3, [Style::FILL_COLOR => '#f99']))
;

$sheet->nextRow();
$sheet->writeCell('topPercent: 10%');
$sheet->writeCells(range(0, 9))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::topPercent(10, [Style::FILL_COLOR => '#ff9']))
;

$sheet->nextRow();
$sheet->writeCell('lowPercent: 10%');
$sheet->writeCells(range(0, 9))
->applyOuterBorder(Style::BORDER_THIN)
->applyConditionalFormatting(Conditional::lowPercent(10, [Style::FILL_COLOR => '#ff9']))
;

// Save to XLSX-file
$excel->save($outFileName);

echo '<b>', basename(__FILE__, '.php'), "</b><br>\n<br>\n";
echo 'out filename: ', $outFileName, "<br>\n";
echo 'elapsed time: ', round(microtime(true) - $timer, 3), ' sec', "<br>\n";
echo 'memory peak usage: ', memory_get_peak_usage(true), "<br>\n";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions docs/90-api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace **avadim\FastExcelWriter**
* [Class RichText](93-api-class-rich-text.md)
* [Class Charts\Chart](94-api-class-chart.md)
* [Class DataValidation\DataValidation](95-api-class-data-validation.md)
* [Class Conditional\Conditional](96-api-class-conditional.md)

---

36 changes: 35 additions & 1 deletion docs/91-api-class-excel.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [addNamedRange()](#addnamedrange)
* [addSharedString()](#addsharedstring)
* [addStyle()](#addstyle)
* [addStyleDxfs()](#addstyledxfs)
* [setAuthor()](#setauthor)
* [setCompany()](#setcompany)
* [setDefaultFont()](#setdefaultfont) -- Set default font options
Expand Down Expand Up @@ -66,6 +67,7 @@
* [sheet()](#sheet) -- Returns sheet by number or name of sheet.
* [getSheet()](#getsheet) -- Alias of sheet()
* [getSheets()](#getsheets) -- Returns all sheets
* [getStyleDxfs()](#getstyledxfs)
* [setSubject()](#setsubject)
* [setTitle()](#settitle)
* [unprotect()](#unprotect) -- Unprotect workbook
Expand Down Expand Up @@ -155,13 +157,14 @@ _Convert letter range to array of numbers (ZERO based)_
---

```php
public static function colKeysToIndexes(array $data): array
public static function colKeysToIndexes(array $data, $offset): array
```


### Parameters

* `array $data`
* `$offset`

---

Expand Down Expand Up @@ -505,6 +508,22 @@ public function addStyle($cellStyle, &$resultStyle): int

---

## addStyleDxfs()

---

```php
public function addStyleDxfs($style, &$resultStyle): int
```


### Parameters

* `$style`
* `$resultStyle`

---

## setAuthor()

---
Expand Down Expand Up @@ -1072,6 +1091,21 @@ public function getSheets(): array
```
_Returns all sheets_

### Parameters

_None_

---

## getStyleDxfs()

---

```php
public function getStyleDxfs(): array
```


### Parameters

_None_
Expand Down
82 changes: 82 additions & 0 deletions docs/92-api-class-sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [setActiveCell()](#setactivecell) -- Set active cell
* [addCellStyle()](#addcellstyle) -- Add additional styles to a cell
* [addChart()](#addchart) -- Add chart object to the specified range of cells
* [addConditionalFormatting()](#addconditionalformatting) -- Add conditional formatting object to the specified range of cells
* [addDataValidation()](#adddatavalidation) -- Add data validation object to the specified range of cells
* [addImage()](#addimage) -- Add image to the sheet from local file, URL or image string in base64
* [addNamedRange()](#addnamedrange) -- Define named range
Expand Down Expand Up @@ -36,6 +37,7 @@
* [applyBorderRight()](#applyborderright)
* [applyBorderTop()](#applybordertop)
* [applyColor()](#applycolor) -- Alias of 'setFontColor()'
* [applyConditionalFormatting()](#applyconditionalformatting)
* [applyDataValidation()](#applydatavalidation)
* [applyFillColor()](#applyfillcolor) -- Fill background color
* [applyFillGradient()](#applyfillgradient) -- Fill background by gradient
Expand Down Expand Up @@ -95,6 +97,7 @@
* [setColWidth()](#setcolwidth) -- Set width of single or multiple column(s)
* [setColWidthAuto()](#setcolwidthauto) -- Set width of single or multiple column(s)
* [setColWidths()](#setcolwidths) -- Setting a multiple column's width
* [getConditionalFormatting()](#getconditionalformatting)
* [getCurrentCell()](#getcurrentcell) -- Returns address of the current cell
* [getCurrentCol()](#getcurrentcol) -- Returns current column letter
* [getCurrentColId()](#getcurrentcolid)
Expand Down Expand Up @@ -158,6 +161,7 @@
* [pagePaperSize()](#pagepapersize) -- Set Paper size (when paperHeight and paperWidth are specified, paperSize should be ignored)
* [pagePaperWidth()](#pagepaperwidth) -- Width of custom paper as a number followed by a unit identifier mm|cm|in (ex: 21cm, 8.5in)
* [pagePortrait()](#pageportrait) -- Set page orientation as Portrait
* [pageScale()](#pagescale)
* [getPageSetup()](#getpagesetup)
* [setPageSetup()](#setpagesetup)
* [setPrintArea()](#setprintarea)
Expand Down Expand Up @@ -193,6 +197,7 @@
* [writeArray()](#writearray) -- Write values from two-dimensional array
* [writeArrayTo()](#writearrayto) -- Write 2d array form the specified cell
* [writeCell()](#writecell) -- Write value to the current cell and move pointer to the next cell in the row
* [writeCells()](#writecells) -- Write several values into cells of one row
* [writeHeader()](#writeheader)
* [writeRow()](#writerow) -- Write values to the current row
* [writeTo()](#writeto) -- Write value to the specified cell and move pointer to the next cell in the row
Expand Down Expand Up @@ -262,6 +267,22 @@ _Add chart object to the specified range of cells_

---

## addConditionalFormatting()

---

```php
public function addConditionalFormatting(string $range, $conditionals): Sheet
```
_Add conditional formatting object to the specified range of cells_

### Parameters

* `string $range`
* `Conditional|Conditional[] $conditionals`

---

## addDataValidation()

---
Expand Down Expand Up @@ -760,6 +781,21 @@ _Alias of 'setFontColor()'_

---

## applyConditionalFormatting()

---

```php
public function applyConditionalFormatting($conditionals): Sheet
```


### Parameters

* `Conditional|Conditional[] $conditionals`

---

## applyDataValidation()

---
Expand Down Expand Up @@ -1756,6 +1792,21 @@ $sheet->setColWidths(['B' => 10, 'C' => 'auto', 'E' => 30, 'F' => 40]);
```


---

## getConditionalFormatting()

---

```php
public function getConditionalFormatting(): array
```


### Parameters

_None_

---

## getCurrentCell()
Expand Down Expand Up @@ -2753,6 +2804,21 @@ _None_

---

## pageScale()

---

```php
public function pageScale(int $scale): Sheet
```


### Parameters

* `int $scale`

---

## getPageSetup()

---
Expand Down Expand Up @@ -3370,6 +3436,22 @@ _Write value to the current cell and move pointer to the next cell in the row_

---

## writeCells()

---

```php
public function writeCells(array $values, ?array $cellStyles = null): Sheet
```
_Write several values into cells of one row_

### Parameters

* `array $values`
* `array|null $cellStyles`

---

## writeHeader()

---
Expand Down
Loading

0 comments on commit 046d132

Please sign in to comment.