Worksheet list
  • The file is not supported for the windows system.
  • Extended version is greater than or equal to 1.2.7;
  • PECL will prompt you to open the read function when installing, please type yes;

Function Prototype

1
sheetList(): array
Copied!

Example

1
$excel = new \Vtiful\Kernel\Excel(['path' => './tests']);
2
3
// Build the sample file
4
$filePath = $excel
5
// First worksheet
6
->fileName('tutorial.xlsx', 'test1')
7
->header(['sheet'])
8
->data([['test1']])
9
10
// Second worksheet
11
->addSheet('test2')
12
->header(['sheet'])
13
->data([['test2']])
14
15
->output();
16
17
// Open the sample file
18
$sheetList = $excel->openFile('tutorial.xlsx')
19
->sheetList();
20
21
Foreach ($sheetList as $sheetName) {
22
echo 'Sheet Name:' . $sheetName . PHP_EOL;
23
24
// Get the worksheet data by the worksheet name
25
$sheetData = $excel
26
->openSheet($sheetName)
27
->getSheetData();
28
29
var_dump($sheetData);
30
}
Copied!

Sample output

1
Sheet Name: test1
2
Array(2) {
3
[0]=>
4
Array(1) {
5
[0]=>
6
String(5) "sheet"
7
}
8
[1]=>
9
Array(1) {
10
[0]=>
11
String(5) "test1"
12
}
13
}
14
Sheet Name: test2
15
Array(2) {
16
[0]=>
17
Array(1) {
18
[0]=>
19
String(5) "sheet"
20
}
21
[1]=>
22
Array(1) {
23
[0]=>
24
String(5) "test2"
25
}
26
}
Copied!
Last modified 2yr ago