@@ -20,79 +20,85 @@ Please see the ```docs/``` and the ```tests/``` directory.
20
20
21
21
### Linux
22
22
23
- // change into php source files directory
24
- cd php-5.x.x
25
-
26
- // clone repository into php extension dir
27
- git clone https://github.com/iliaal/php_excel.git ext/excel
28
-
29
- // rebuild configure
30
- ./buildconf --force
31
-
32
- // replace <PATH> with the file path to the extracted libxl files
33
- // on a 32-bit platform use
34
- ./configure --with-excel --with-libxl-incdir=<PATH>/libxl-3.6.0.1/include_c --with-libxl-libdir=<PATH>/libxl-3.6.0.1/lib
35
-
36
- // on a 64-bit platform use
37
- ./configure --with-excel --with-libxl-incdir=<PATH>/libxl-3.6.0.1/include_c --with-libxl-libdir=<PATH>/libxl-3.6.0.1/lib64
23
+ ``` shell
24
+ # change into php source files directory
25
+ cd php-5.x.x
38
26
27
+ # clone repository into php extension dir
28
+ git clone https://github.com/iliaal/php_excel.git ext/excel
29
+
30
+ # rebuild configure
31
+ ./buildconf --force
32
+
33
+ # replace <PATH> with the file path to the extracted libxl files
34
+ # on a 32-bit platform use
35
+ ./configure --with-excel --with-libxl-incdir=< PATH> /libxl-3.6.0.1/include_c --with-libxl-libdir=< PATH> /libxl-3.6.0.1/lib
36
+
37
+ # on a 64-bit platform use
38
+ ./configure --with-excel --with-libxl-incdir=< PATH> /libxl-3.6.0.1/include_c --with-libxl-libdir=< PATH> /libxl-3.6.0.1/lib64
39
+ ```
40
+
39
41
### Windows
40
42
41
43
Pre-build packages for Windows can be downloaded [ here] ( http://windows.php.net/downloads/pecl/snaps/excel ) .
42
44
43
45
## Getting started
44
46
45
- <?php
46
-
47
- // init excel work book as xlsx
48
- $useXlsxFormat = true;
49
- $xlBook = new \ExcelBook('<YOUR_LICENSE_NAME>', '<YOUR_LICENSE_KEY>', $useXlsxFormat);
50
- $xlBook->setLocale('UTF-8');
51
-
52
- // add sheet to work book
53
- $xlSheet1 = $xlBook->addSheet('Sheet1');
54
-
55
- // create a small sample data set
56
- $dataset = [
57
- [1, 1500, 'John', 'Doe'],
58
- [2, 750, 'Jane', 'Doe']
59
- ];
60
-
61
- // write data set to sheet
62
- $row = 1;
63
- foreach($dataset as $item){
64
- $xlSheet1->writeRow($row, $item);
65
- $row++;
66
- }
67
-
68
- // write sum formula under data set
69
- $col = 1;
70
- $xlSheet1->write($row, $col, '=SUM(B1:B3)');
71
-
72
- // add second sheet to work book
73
- $xlSheet2 = $xlBook->addSheet('Sheet2');
74
-
75
- // add a date with specific date format to second sheet
76
- $row = 1; $col = 0;
77
- $date = new \DateTime('2014-08-02');
78
- $dateFormat = new \ExcelFormat($xlBook);
79
- $dateFormat->numberFormat(\ExcelFormat::NUMFORMAT_DATE);
80
- $xlSheet2->write($row, $col, $date->getTimestamp(), $dateFormat, \ExcelFormat::AS_DATE);
81
-
82
- // save workbook
83
- $xlBook->save('test.xlsx');
47
+ ``` php
48
+ <?php
49
+
50
+ // init excel work book as xlsx
51
+ $useXlsxFormat = true;
52
+ $xlBook = new \ExcelBook('<YOUR _LICENSE_NAME >', '<YOUR _LICENSE_KEY >', $useXlsxFormat);
53
+ $xlBook->setLocale('UTF-8');
54
+
55
+ // add sheet to work book
56
+ $xlSheet1 = $xlBook->addSheet('Sheet1');
57
+
58
+ // create a small sample data set
59
+ $dataset = [
60
+ [1, 1500, 'John', 'Doe'],
61
+ [2, 750, 'Jane', 'Doe']
62
+ ];
63
+
64
+ // write data set to sheet
65
+ $row = 1;
66
+ foreach($dataset as $item){
67
+ $xlSheet1->writeRow($row, $item);
68
+ $row++;
69
+ }
70
+
71
+ // write sum formula under data set
72
+ $col = 1;
73
+ $xlSheet1->write($row, $col, '=SUM(B1:B3)');
74
+
75
+ // add second sheet to work book
76
+ $xlSheet2 = $xlBook->addSheet('Sheet2');
77
+
78
+ // add a date with specific date format to second sheet
79
+ $row = 1; $col = 0;
80
+ $date = new \DateTime('2014-08-02');
81
+ $dateFormat = new \ExcelFormat($xlBook);
82
+ $dateFormat->numberFormat(\ExcelFormat::NUMFORMAT_DATE);
83
+ $xlSheet2->write($row, $col, $date->getTimestamp(), $dateFormat, \ExcelFormat::AS_DATE);
84
+
85
+ // save workbook
86
+ $xlBook->save('test.xlsx');
87
+ ```
84
88
85
89
## optional php.ini settings
86
90
87
91
To prevent unvealing your credentials in your code you can save them in your php.ini file.
88
92
They will be automatically fetched by the extension and you can pass ``` null ``` instead of
89
93
your credentials ``` new \ExcelBook(null, null, $useXlsxFormat) ``` .
90
94
91
- ; optional settings for excel extension
92
- [excel]
93
- excel.license_name="<YOUR_LICENSE_NAME>"
94
- excel.license_key="<YOUR_LICENSE_KEY>"
95
- excel.skip_empty=0
95
+ ``` ini
96
+ ; optional settings for excel extension
97
+ [excel]
98
+ excel.license_name =" <YOUR_LICENSE_NAME>"
99
+ excel.license_key =" <YOUR_LICENSE_KEY>"
100
+ excel.skip_empty =0
101
+ ```
96
102
97
103
## Known Issues
98
104
0 commit comments