PHP Classes

Get worksheet name

Recommend this page to a friend!

      SimpleXLSX  >  All threads  >  Get worksheet name  >  (Un) Subscribe thread alerts  
Subject:Get worksheet name
Summary:Get worksheet name function
Messages:4
Author:SPYRO KiD
Date:2011-05-08 09:15:20
Update:2012-09-14 02:34:04
 

  1. Get worksheet name   Reply   Report abuse  
Picture of SPYRO KiD SPYRO KiD - 2011-05-08 09:15:21
Hi,
Your code is awsome ^_*
I'm using your code for my project, thank you very much :)
BTW, i need to display the worksheet name, so i add the following function into your class:

//$xlsx->getWorksheetName() - List All worksheet name
//$xlsx->getWorksheetName(1) - Get first Worksheet name

function getWorksheetName($dimId = 0){
$xmlWorkBook = simplexml_load_string( $this->getEntryData("xl/workbook.xml") );
if($dimId==0){
//Get All worksheet name
$worksheetName = "<ul>";
foreach ($xmlWorkBook->sheets->sheet as $sheetName) {
$worksheetName .= "<li>".$sheetName['name']."</li>";
}
$worksheetName .= "</ul>";
return $worksheetName;
}else{
//get worksheet name by id
return $xmlWorkBook->sheets->sheet[$dimId-1]->attributes()->name;
}
}

If you have a beter code, please add function to get Worksheet name into your class, maybe it will help someone.

Thank you :)

  2. Re: Get worksheet name   Reply   Report abuse  
Picture of SPYRO KiD SPYRO KiD - 2011-05-09 00:50:06 - In reply to message 1 from SPYRO KiD
Store the result into array:

function getWorksheetName($dimId = 0){
$worksheetName = array();
$xmlWorkBook = simplexml_load_string( $this->getEntryData("xl/workbook.xml") );
if($dimId==0){
foreach ($xmlWorkBook->sheets->sheet as $sheetName) {
$worksheetName[] = $sheetName['name'];
}
}else{
$worksheetName[] = $xmlWorkBook->sheets->sheet[$dimId-1]->attributes()->name;
}
return $worksheetName;
}

  3. Re: Get worksheet name   Reply   Report abuse  
Picture of Sergey Shuchkin Sergey Shuchkin - 2011-05-10 03:27:12 - In reply to message 2 from SPYRO KiD
thx, I'll add these methods in next release.

  4. Re: Get worksheet name   Reply   Report abuse  
Picture of Sergey Shuchkin Sergey Shuchkin - 2012-09-14 02:34:04 - In reply to message 1 from SPYRO KiD
v0.6 added
- sheetName( $id )