问题
- Given a spreadsheet with N logical rows
- Where one row is totally blank*
cfspreadsheet action="read"
will return a query with aRecordCount
of N - 1.
*A totally blank row is a row where every cell is actually blank. See CELL_TYPE_BLANK in the POI docs.
Is it possible for cfspreadsheet
to include empty rows?
回答1:
No. Since spreadsheet data is not always contiguous, <cfspreadsheet action="read" query="queryName" ...>
and <cfspreadsheet action="read" format="csv|html" ..>
deliberately screen out blank rows to avoid including tons of white space noise. So unless a row has at least one non blank cell, it will not be detected. AFAIK, there is no setting to override that behavior. You would have to tap into the underlying POI workbook and roll-your-own.
回答2:
I set up an xls like this:
|Row1|Data1|
[blank]
|Row3|Data3|
[blank]
|Row5|Data5|
And ran this code over it:
<cfspreadsheet action="read" src="c:\temp\book1.xlsx" name="st1">
<table border="1">
<cfloop index="iRow" from="1" to="5">
<tr>
<cfloop index="iCol" from="1" to="2">
<cfoutput><td>#spreadsheetGetCellValue(st1, iRow, iCol)# </td></cfoutput>
</cfloop>
</tr>
</cfloop>
</table>
And the output was:
|Row1|Data1|
[blank]
|Row3|Data3|
[blank]
|Row5|Data5|
Which is what I'd expect.
So it looks to me like the blank rows are respected just fine...?
What am I doing different from you?
来源:https://stackoverflow.com/questions/8058144/cfspreadsheet-fails-to-read-empty-rows