|
1
|
|
|
<?php namespace Arcanedev\LaravelExcel; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanedev\LaravelExcel\Contracts\ImporterManager as ImporterManagerContract; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class ImporterManager |
|
7
|
|
|
* |
|
8
|
|
|
* @package Arcanedev\LaravelExcel |
|
9
|
|
|
* @author ARCANEDEV <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
class ImporterManager extends AbstractManager implements ImporterManagerContract |
|
12
|
|
|
{ |
|
13
|
|
|
/* ----------------------------------------------------------------- |
|
14
|
|
|
| Main Drivers |
|
15
|
|
|
| ----------------------------------------------------------------- |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Get a importer instance. |
|
20
|
|
|
* |
|
21
|
|
|
* @param string $driver |
|
22
|
|
|
* |
|
23
|
|
|
* @return \Arcanedev\LaravelExcel\Contracts\Importer |
|
24
|
|
|
*/ |
|
25
|
12 |
|
public function make($driver) |
|
26
|
|
|
{ |
|
27
|
12 |
|
return $this->driver($driver); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Get the Excel driver instance. |
|
32
|
|
|
* |
|
33
|
|
|
* @return \Arcanedev\LaravelExcel\Contracts\Importer |
|
34
|
|
|
*/ |
|
35
|
6 |
|
public function createExcelDriver() |
|
36
|
|
|
{ |
|
37
|
6 |
|
return $this->buildImporter('excel'); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Get the CSV driver instance. |
|
42
|
|
|
* |
|
43
|
|
|
* @return \Arcanedev\LaravelExcel\Contracts\Importer |
|
44
|
|
|
*/ |
|
45
|
3 |
|
public function createCsvDriver() |
|
46
|
|
|
{ |
|
47
|
3 |
|
return $this->buildImporter('csv'); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Get the Open office driver instance. |
|
52
|
|
|
* |
|
53
|
|
|
* @return \Arcanedev\LaravelExcel\Contracts\Importer |
|
54
|
|
|
*/ |
|
55
|
3 |
|
public function createOpenOfficeDriver() |
|
56
|
|
|
{ |
|
57
|
3 |
|
return $this->buildImporter('ods'); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/* ----------------------------------------------------------------- |
|
61
|
|
|
| Other Methods |
|
62
|
|
|
| ----------------------------------------------------------------- |
|
63
|
|
|
*/ |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Build the importer. |
|
67
|
|
|
* |
|
68
|
|
|
* @param string $driver |
|
69
|
|
|
* |
|
70
|
|
|
* @return \Arcanedev\LaravelExcel\Contracts\Importer |
|
71
|
|
|
*/ |
|
72
|
12 |
|
protected function buildImporter($driver) |
|
73
|
|
|
{ |
|
74
|
12 |
|
return $this->app->makeWith( |
|
75
|
12 |
|
$this->getDriverImporter($driver), |
|
76
|
12 |
|
$this->getDriverOptions($driver) |
|
77
|
|
|
); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|