I am trying to recover only some values from an xlsx file. The file that creates problems for me is worksheets / sheet1.xml whose structure is …
JavaScript
x
<sheetData>
<row (attribbutes)>
<c (attributes)>
<v>value</v>
</c>
..
<c (attributes)>
<v>value</v>
</c>
</row>
<row (attribbutes)>
<c (attributes)>
<v>value</v>
</c>
..
<c (attributes)>
<v>value</v>
</c>
</row>
</sheetData>
my problem is that the values that interest me are in different lines but they can be the same. For example: I need the number of the day of the month (e.g. 16), but that number is also the pointer that allows me to find the name of a colleague and when I read the attributes of the row I don’t find what I expect. Following is the code I use
JavaScript
$sheet1 = 'sheet1.xml';
$getrow = file_get_contents($sheet1);
$xmlrow = simplexml_load_string($getrow);
foreach ($xmlrow->sheetData->row as $row_0) {
foreach ($row_0->c as $c_0)
{
foreach ($c_0->v as $v)
{
if ($v[0] == $preserve) /****** This changes when search for number day of the month (if $v == $day)
{
$attr_0 = $c_0->attributes();
$row = $attr_0['r'];
break 3;
}
}
}
}
How can I get the correct value in the correct row?
Advertisement
Answer
Problem solved.
In the above code $row = $attr_0['r'];
$row becomes an array $row[] and analyze it.
Thank Nigel Ren for givin me an inspiration