سؤال

  1. Given a spreadsheet with N logical rows
  2. Where one row is totally blank*
  3. cfspreadsheet action="read" will return a query with a RecordCount 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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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)#&nbsp;</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?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top