I'm fiddeling with a template that will update a DB with data from an Excel
file... and run inte a a wierd thing on the query object.
For some reason it adds an extra row to my query object.
I have an Excel sheet with some 400 rows for test, 4 columns, reading
through this sheet till is get the first empty Cell.
<cfset iRow = 1 />
<cfset iCol = 1 />
<cfset bDone = 1 />
<cfset qExcel = QueryNew("field1, field2, field3, field4")>
<cfset newRow = QueryAddRow(qExcel, 1)>
<cftry>
<cfset xlsObj = SpreadsheetRead('/mypath/test_excel.xls') />
<cfloop condition="bDone EQUAL 1">
<cfloop from="1" to="4" index="iCol">
<cfset sVal = SpreadsheetGetcellvalue(xlsObj, iRow, iCol) />
<cfif Trim(sVal) IS NOT "" or sVal IS NOT NULL>
<cfset dummy = QuerySetCell(qExcel, "field#iCol#", "#sVal#", iRow)
/>
</cfif>
</cfloop>
<cfif Trim(sVal) IS ""><cfset bDone = 0 /></cfif>
<!--- Eventhough I check that the Cell NOT Epmty it seems to add 1 row
!!! --->
<cfif Trim(sVal) IS NOT "" OR bDone IS 1><cfset newRow =
QueryAddRow(qExcel, 1)></cfif>
<cfset iRow = iRow + 1 />
<cfif bDone IS 0><cfbreak></cfif>
</cfloop>
<table border="0" cellspacing="2">
<cfoutput query="qExcel">
<tr>
<cfif #field1# IS NOT "">
<td><em>#CurrentRow#</em></td><td>#field1#</td><td>#field2#</td><td>#field3#</td><td>#field4#</td></cfif>
</tr>
</cfoutput>
</table>
<cfdump var="#bDummy#">
<cfdump var="#xlsObj#">
<cfcatch type="any">
<cfdump var="#cfcatch#">
<cfdump var="#xlsObj#">
</cfcatch>
</cftry>
Either I'm simply doing something stupid in the logic of this looping or
there is an "un-documented feature" in OpenBD ?
/Mats/
--
official tag/function reference: http://openbd.org/manual/
mailing list - http://groups.google.com/group/openbd?hl=en