Skip to content

Commit a841d58

Browse files
Add 2.1 docs
1 parent 2918493 commit a841d58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1936
-139
lines changed

.vuepress/2.1.js

+78-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,80 @@
11
module.exports = [
2-
{
3-
title: 'Getting Started',
4-
collapsable: false,
5-
children: ['installation'],
6-
},
2+
{
3+
title: 'Getting Started',
4+
collapsable: false,
5+
children: prefix('getting-started', [
6+
'',
7+
'config',
8+
'requirements',
9+
'contributing',
10+
'license'
11+
]),
12+
},
13+
{
14+
title: 'Imports',
15+
collapsable: false,
16+
children: prefix('import', [
17+
'',
18+
'injection',
19+
'results',
20+
'select',
21+
'dates',
22+
'calculation',
23+
'formatting',
24+
'cache',
25+
'chunk',
26+
'batch',
27+
'config',
28+
'edit',
29+
'convert',
30+
'extra'
31+
]),
32+
},
33+
{
34+
title: 'Exports',
35+
collapsable: false,
36+
children: prefix('export', [
37+
'',
38+
'export',
39+
'injection',
40+
'store',
41+
'sheets',
42+
'array',
43+
'rows',
44+
'cells',
45+
'sheet-styling',
46+
'freeze',
47+
'autofilter',
48+
'sizing',
49+
'autosize',
50+
'merge',
51+
'format',
52+
'call'
53+
]),
54+
},
55+
{
56+
title: 'Blade to Excel',
57+
collapsable: false,
58+
children: prefix('blade', [
59+
'load-view',
60+
'vars',
61+
'styling',
62+
]),
63+
},
64+
{
65+
title: 'Reference Guide',
66+
collapsable: false,
67+
children: prefix('reference-guide', [
68+
'file-properties',
69+
'sheet-properties',
70+
'css-styles',
71+
'borders',
72+
'formatting',
73+
'closures'
74+
]),
75+
}
776
];
77+
78+
function prefix(prefix, children) {
79+
return children.map(child => `${prefix}/${child}`)
80+
}

.vuepress/3.0.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ module.exports = [
3434

3535
function prefix(prefix, children) {
3636
return children.map(child => `${prefix}/${child}`)
37-
}
37+
}

.vuepress/config.js

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,42 @@
11
module.exports = {
22
title: 'Laravel Excel',
33
description: 'Supercharged Excel exports in Laravel',
4+
ga: 'UA-775649-7',
5+
serviceWorker: true,
6+
7+
markdown: {
8+
lineNumbers: true,
9+
},
410

511
head: [
612
[
713
'link',
814
{
9-
href:
10-
'https://fonts.googleapis.com/css?family=Source+Sans+Pro:100,300,400,500,600,700',
15+
href: 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:100,300,400,500,600,700',
1116
rel: 'stylesheet',
1217
type: 'text/css',
1318
},
1419
],
1520
],
1621

1722
themeConfig: {
18-
logo: '/assets/img/logo.png',
19-
repo: 'maatwebsite/laravel-excel',
23+
logo: '/assets/img/logo-small.png',
24+
repo: 'maatwebsite/Laravel-Excel',
2025
docsRepo: 'maatwebsite/laravel-excel-docs',
2126
docsBranch: 'master',
2227
editLinks: true,
2328
editLinkText: 'Help us improve this page!',
2429
displayAllHeaders: false,
2530
sidebarDepth: 0,
31+
algolia: {
32+
apiKey: 'e95794f59bac5401e3930f71feb3a8e2',
33+
indexName: 'laravel_excel',
34+
algoliaOptions: { 'facetFilters': ["version:3.0"] },
35+
},
36+
37+
serviceWorker: {
38+
updatePopup: true
39+
},
2640

2741
nav: [
2842
{

.vuepress/public/assets/img/hero.png

-20.5 KB
Binary file not shown.
3.64 KB
Loading

.vuepress/public/assets/img/logo.png

-21.5 KB
Binary file not shown.

.vuepress/style.styl

-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ body
22
background-color #f7fafc
33
font-family "Source Sans Pro"
44

5-
.content:not(.custom), .page-edit, .page-nav
6-
margin : 0
7-
85
.home .hero img
96
margin-bottom 0
107

118
.home .hero h1
129
margin : 0.2rem auto;
1310
font-size : 2.5rem;
14-
color : #4dc0b5
1511

1612
.home .hero .description
1713
margin : 0.4rem auto;

2.1/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<meta http-equiv="refresh" content="0;url=/2.1/installation.html" />
1+
<meta http-equiv="refresh" content="0;url=/2.1/getting-started/" />

2.1/blade/load-view.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# @Blade to Excel
2+
3+
We can utilise the magic of Laravel's Blade engine to power our Excel export. Sharing a view, loading a view per sheet, creating a html table inside a view, basic CSS styling, ...
4+
5+
# Loading a view for a single sheet
6+
7+
We can load a view for every sheet we create with `->loadView()`.
8+
9+
Excel::create('New file', function($excel) {
10+
11+
$excel->sheet('New sheet', function($sheet) {
12+
13+
$sheet->loadView('folder.view');
14+
15+
});
16+
17+
});
18+
19+
# Using different views for different sheets
20+
21+
Excel::create('New file', function($excel) {
22+
23+
$excel->sheet('First sheet', function($sheet) {
24+
25+
$sheet->loadView('view_first');
26+
});
27+
28+
$excel->sheet('Second sheet', function($sheet) {
29+
30+
$sheet->loadView('view_second');
31+
});
32+
33+
});
34+
35+
# Sharing a view for all sheets
36+
37+
We can share a view for all sheets with `shareView()`.
38+
39+
Excel::shareView('folder.view')->create();
40+
41+
# Unsetting a view for a sheet
42+
43+
When we are using a shared view, but we don't want to use a view for the current sheet, we can use `->unsetView()`.
44+
45+
$sheet->unsetView();

2.1/blade/styling.md

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Styling sheets
2+
3+
### General styling
4+
5+
If you want to change the general styling of your sheet (not cell or range specific), you can use the `->setStyle()` method or any of the other setters which can be found inside the export documentation.
6+
7+
// Font family
8+
$sheet->setFontFamily('Comic Sans MS');
9+
10+
// Set font with ->setStyle()`
11+
$sheet->setStyle(array(
12+
'font' => array(
13+
'name' => 'Calibri',
14+
'size' => 12,
15+
'bold' => true
16+
)
17+
));
18+
19+
### Styling with PHPExcel methods
20+
21+
It's possible to style the sheets and specific cells with help of PHPExcel methods. This package includes a lot of shortcuts (see export documentation), but also always the use of the native methods.
22+
23+
// Set background color for a specific cell
24+
$sheet->getStyle('A1')->applyFromArray(array(
25+
'fill' => array(
26+
'type' => PHPExcel_Style_Fill::FILL_SOLID,
27+
'color' => array('rgb' => 'FF0000')
28+
)
29+
));
30+
31+
### Using HTML tags
32+
33+
Most of the HTML tags are supported.
34+
35+
<html>
36+
37+
<!-- Headings -->
38+
<td><h1>Big title</h1></td>
39+
40+
<!-- Bold -->
41+
<td><b>Bold cell</b></td>
42+
<td><strong>Bold cell</strong></td>
43+
44+
<!-- Italic -->
45+
<td><i>Italic cell</i></td>
46+
47+
<!-- Images -->
48+
<td><img src="img.jpg" /></td>
49+
50+
</html>
51+
52+
> Inside the `view.php` config you can change how these tags will be interpreted by Excel by default.
53+
54+
### Using HTML attributes
55+
56+
Some of the basic styling can be done with HTML attributes.
57+
58+
<html>
59+
60+
<!-- Horizontal alignment -->
61+
<td align="right">Big title</td>
62+
63+
<!-- Vertical alignment -->
64+
<td valign="middle">Bold cell</td>
65+
66+
<!-- Rowspan -->
67+
<td rowspan="3">Bold cell</td>
68+
69+
<!-- Colspan -->
70+
<td colspan="6">Italic cell</td>
71+
72+
<!-- Width -->
73+
<td width="100">Cell with width of 100</td>
74+
75+
<!-- Height -->
76+
<td height="100">Cell with height of 100</td>
77+
78+
</html>
79+
80+
### Styling through inline-styles
81+
82+
It's possible to use inline styles inside your view files. Most of the general styles are supported.
83+
84+
<html>
85+
86+
<!-- Cell with black background -->
87+
<td style="background-color: #000000;">Cell</td>
88+
89+
</html>
90+
91+
> Inside the reference guide you can find a list of supported styles.
92+
93+
### Styling through external CSS file
94+
95+
Styling can be done through an external CSS file.
96+
97+
External css file:
98+
99+
#cell {
100+
background-color: #000000;
101+
color: #ffffff;
102+
}
103+
104+
.cell {
105+
background-color: #000000;
106+
color: #ffffff;
107+
}
108+
109+
tr td {
110+
background-color: #ffffff;
111+
}
112+
113+
tr > td {
114+
border-bottom: 1px solid #000000;
115+
}
116+
117+
Table:
118+
119+
```html
120+
<html>
121+
{{ HTML::style('css/table.css') }}
122+
123+
<!-- Cell styled with class -->
124+
<td class="cell">Cell</td>
125+
126+
<!-- Cell styled with ID -->
127+
<td id="cell">Cell</td>
128+
</html>
129+
```
130+
131+
> Inside the reference guide you can find a list of supported styles.
132+
133+
> It's advised to include `<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />` into the view to fix problems with UTF-8 encoding.

2.1/blade/vars.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Passing variables to the view
2+
3+
### As parameter
4+
5+
We can pass variables to the view by using the second parameter inside the `loadView()` method.
6+
7+
$sheet->loadView('view', array('key' => 'value'));
8+
9+
### With with()
10+
11+
Alternatively you can use the `with()` method which works the same as with Laravel views.
12+
13+
// Using normal with()
14+
$sheet->loadView('view')
15+
->with('key', 'value');
16+
17+
// using dynamic with()
18+
$sheet->loadView('view')
19+
->withKey('value');

0 commit comments

Comments
 (0)