Skip to content

Commit 504daaf

Browse files
committed
init vitepress
1 parent 33bb86f commit 504daaf

18 files changed

+139
-78
lines changed

README.md

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,59 @@ Once the data is received, the Rust binary uses the **excelrust** library to cre
2222

2323
`composer require spiriitlabs/rustsheet`
2424

25-
# Two way for use
25+
# Download the last release of the rust binary
2626

27-
## With WorkbookFactory
27+
Go at https://github.com/SpiriitLabs/excel_gen
2828

29-
First create a class implements `ExcelInterface` and add attribute 'AsExcelRust'
29+
Save the binary somewhere
30+
31+
# Symfony bundle
32+
33+
Just active the bundle in your `bundles.php`
34+
35+
```php
36+
Spiriit\Rustsheet\Symfony\Bundle\ExcelRustBundle::class => ['all' => true],
37+
```
38+
39+
Create a file in the folder packages
40+
41+
> config/packages/spiriit_excel_rust.yaml
42+
43+
```yaml
44+
excel_rust:
45+
rust_binary: '%rust_binary%' # path to rust binary
46+
avro_codec: 'null' # default to null, because we don't need to compress the file
47+
```
48+
49+
You need to use the `AsExcelRust` attribute
3050

3151
```php
3252
use Spiriit\Rustsheet\Attributes\AsExcelRust;
3353
34-
#[AsExcelRust(outputName: "myexcel.xlsx")] // optionnal outputName
54+
#[AsExcelRust(name: 'my_super_excel')] // override name is optionnal
55+
class MyExcel implements ExcelInterface
56+
{
57+
...
58+
}
59+
```
60+
61+
```php
62+
class MyController
63+
{
64+
public function __invoke(ExcelRust $excelRust)
65+
{
66+
$output = $excelRust->generateExcelFromAvro('MyExcel', __DIR__.'/myexcel_avro.xlsx');
67+
}
68+
}
69+
```
70+
71+
# Use the library in standalone
72+
73+
## Use a builder
74+
75+
First create a class implements `ExcelInterface` and add attribute 'AsExcelRust'
76+
77+
```php
3578
class MyExcel implements ExcelInterface
3679
{
3780
public function buildSheet(WorkbookBuilder $builder): void
@@ -66,28 +109,34 @@ class MyExcel implements ExcelInterface
66109
Then create a new instance of ExcelRust and prepare the WorkbookFactory and the excel_rust binary:
67110

68111
```php
69-
$excelGeneratorFromAvro = new ExcelRust(
70-
workbookFactory: new WorkbookFactory(),
71-
rustGenLocation: __DIR__ . '/../vendor/bin/excel_gen'
112+
$factory = new \Spiriit\Rustsheet\WorkbookFactory();
113+
114+
$exportAvro = new ExportAvro(
115+
schema: file_get_contents(__DIR__.'/../schema.json')
116+
);
117+
118+
$excelRust = new ExcelRust(
119+
workbookFactory: $factory,
120+
rustGenLocation: __DIR__ . '/path/to/excel_gen',
121+
exportAvro: $exportAvro,
72122
);
73-
$excelGeneratorFromAvro->setLogger(new NullLogger());
74123
75-
$excelGeneratorFromAvro->generateExcelFromAvro(new MyExcel());
124+
$output = $excelRust->generateExcelFromAvro(new MyExcel(), __DIR__.'/myexcel_avro.xlsx');
125+
76126
```
77127

78128
## From HTML file
79129

80130
```php
81-
$output = '/tmp/output.xlsx';
82-
83-
$avroFactory = new ExcelRust(
84-
workbookFactory: new WorkbookFactory(),
85-
rustGenLocation: __DIR__ . '/../vendor/bin/excel_gen'
131+
$factory = new \Spiriit\Rustsheet\WorkbookFactory();
132+
133+
$excelRust = new ExcelRust(
134+
workbookFactory: $factory,
135+
rustGenLocation: __DIR__ . '/path/to/excel_gen',
86136
);
87-
$avroFactory->setLogger(new NullLogger());
88137
89-
$htmlFile = 'fixtures.html';
138+
$htmlFile = 'test.html';
90139
91-
$avroFactory->generateExcelFromHtml($htmlFile, $output);
140+
$excelRust->generateExcelFromHtml($htmlFile, $output);
92141
```
93142

docs/.vitepress/config.mts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@ import { defineConfig } from 'vitepress'
22

33
// https://vitepress.dev/reference/site-config
44
export default defineConfig({
5-
base: 'php-excel-rust',
5+
base: '/',
66
title: "Excel Rust",
77
description: "Supercharge Excel generation in PHP with Rust's blazing speed!",
88
themeConfig: {
99
// https://vitepress.dev/reference/default-theme-config
1010
nav: [
11-
{ text: 'Home', link: '/' },
12-
{ text: 'Examples', link: '/markdown-examples' }
11+
{ text: 'PHP', link: '/php-readme' },
12+
{ text: 'Symfony Bundle', link: '/symfony-bundle' },
13+
{ text: 'Rust', link: '/rust-excel' }
1314
],
1415

1516
sidebar: [
1617
{
17-
text: 'Examples',
18+
text: 'PHP',
1819
items: [
1920
{ text: 'Markdown Examples', link: '/markdown-examples' },
2021
{ text: 'Runtime API Examples', link: '/api-examples' }
@@ -23,7 +24,7 @@ export default defineConfig({
2324
],
2425

2526
socialLinks: [
26-
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
27+
{ icon: 'github', link: 'https://github.com/SpiriitLabs/php-excel-rust' }
2728
]
2829
}
2930
})

docs/index.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ hero:
77
tagline: "PHP to Excel in less than a millisecond!"
88
actions:
99
- theme: brand
10-
text: Markdown Examples
11-
link: /markdown-examples
10+
text: Getting started
11+
link: /php-readme
1212
- theme: alt
13-
text: API Examples
14-
link: /api-examples
13+
text: Rust
14+
link: /rust-excel
1515

1616
features:
17-
- title: Feature A
18-
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
19-
- title: Feature B
20-
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
21-
- title: Feature C
22-
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
17+
- title: HTML to Excel
18+
icon:
19+
src: /rust-logo-blk.svg
20+
details: ~80x times faster than PHP phpoffice/phpspreadsheet for HTML file
21+
- title: Generate Fast Excel
22+
icon: 🚀
23+
details: Fast generation of Excel! 3x times faster than phpoffice/phpspreadsheet
24+
- title: Focus on Your Data
25+
icon: 🗂️
26+
details: Effortlessly create Excel with basic formats.
2327
---
2428

docs/php-readme.md

Whitespace-only changes.

docs/public/rust-logo-blk.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/rust-excel.md

Whitespace-only changes.

docs/symfony-bundle.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Symfony Bundle

examples/WorkbookFactoryStub.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/example_avro.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
<?php
22

33
require __DIR__.'/../vendor/autoload.php';
4-
require __DIR__.'/WorkbookFactoryStub.php';
54

65
use Spiriit\Rustsheet\ExcelRust;
76
use Spiriit\Tests\Fixtures\MyExcel;
87
use Psr\Log\NullLogger;
98
use Spiriit\Rustsheet\ExportAvro\ExportAvro;
109

11-
@unlink($output = __DIR__.'/../myexcel.xlsx');
12-
13-
$factory = new WorkbookFactoryStub();
10+
$factory = new \Spiriit\Rustsheet\WorkbookFactory();
1411

1512
$exportAvro = new ExportAvro(
1613
schema: file_get_contents(__DIR__.'/../schema.json')

examples/example_html.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<?php
22

33
require __DIR__.'/../vendor/autoload.php';
4-
require __DIR__.'/WorkbookFactoryStub.php';
54

65
use Spiriit\Rustsheet\ExcelRust;
76
use Psr\Log\NullLogger;
87

98
@unlink($output = __DIR__.'/myexcel_html.xlsx');
109

11-
$factory = new WorkbookFactoryStub();
10+
$factory = new \Spiriit\Rustsheet\WorkbookFactory();
1211

1312
$excelRust = new ExcelRust(
1413
workbookFactory: $factory,

0 commit comments

Comments
 (0)