athin / php-excel-reader

Automatically exported from code.google.com/p/php-excel-reader
0 stars 0 forks source link

select a specific sheet by its name #100

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
hi there !

I would like to know if it's possible to load a specific sheet by using its 
name ?

for example echo $data->dump(true,true,'mySheet1');

Original issue reported on code.google.com by jbmais...@gmail.com on 2 Dec 2010 at 2:46

GoogleCodeExporter commented 9 years ago
Hi jbmaisner,
you can add a function to the class Spreadsheet_Excel_Reader like described in 
buabco's comment (Feb 16, 2010) on the documentation site.
After that modification you can access the sheet by it's name:
$data->dump(true, true, $data->getSheetIndex('mySheet1'));
Regards,
Armin

Original comment by goo...@arminpech.de on 9 Jan 2011 at 11:39

GoogleCodeExporter commented 9 years ago
Hi,I have a problem to get the Index sheet.
With only one sheet, the script works fine but when there are several sheets, 
it doesn't work.
So I want to load a specific sheet of my file :

In this function :
'function getSheetIndex($label) {
    foreach ($this -> boundsheets as $key => $item)
        if ($item['name'] == $label)
            return $key;

    return false;
}'

What is the attending parameter in $item['name'] ?

In my file example3.php, i use :
$sheet = $data->getSheetIndex('form');

But it doesn't work ...

I want to parse the sheet "form" in my xls file

Can you help me ??

Original comment by vincent....@gmail.com on 21 Feb 2011 at 3:49

GoogleCodeExporter commented 9 years ago
I have successfully implemented a sheet upon request. You see the following 
example.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="table.css"
</head>

<body>
<?php
    $filename="demo1.xls"; 
    require_once 'excel_reader2_patch_applied.php';
    $data = new Spreadsheet_Excel_Reader($filename,true);
    $i=$data->getSheetIndex('demo1');
    echo $data->dump(true,true,$i); 
?>
</body>
</html>

Hope this helped you

Original comment by Hienktk...@gmail.com on 16 Mar 2011 at 8:18

Attachments: