I'm working on a little app that takes Excel spreadsheets that display tournament brackets, and then output the excel data and formatting into xml. I'm using Spreadsheet_Excel_Reader (https://code.google.com/archive/p/php-excel-reader/) to retrieve the data from the tournament bracket spreadsheets. The only problem is that 开发者_C百科any cell will no value will not be put in the Spreadsheet_Excel_Reader->sheets[0]['cells']
array, thus causing the table cell borders to not output. It appears that if I put a space in each cell that I want display, it works fine, but that seems like a pretty hackey way of doing it. Does anyone if there is a better way to output the formatting of a blank cell using the Spreadsheet_Excel_Reader?
I found this question after having the same problem (a spreadsheet row with 5 columns, 2 of them blank, are shown as an array of 3 items, omitting the 2 empty cells).
It took longer than I wanted it to, but I think I figured it out. When you dump your row data, check out the indexes.
array(5) {
["maxrow"]=>
int(0)
["maxcol"]=>
int(0)
["numRows"]=>
int(2)
["numCols"]=>
int(3)
["cells"]=>
array(2) {
[1]=>
array(2) {
[1]=>
string(4) "test"
[2]=>
string(3) "xls"
}
[2]=>
array(2) {
[1]=>
string(5) "empty"
[3]=>
string(4) "test"
}
}
}
In my case, I have an empty cell in the second row, between "empty" and "test", and I can see that "test" as the index '3'.
What you (and I) need to do is, instead of using foreach(), be sure to iterate over each expected index using for() or foreach(range()) ending at numCols.
精彩评论