0

I need to do some validation on an excel spreadsheet before I upload to database.

How do I query through an excel document column using cfspreadsheet in ColdFusion?

I need to verify that specific columns don't have any null values in any of their rows. I have the number of rows in a cold Fusion variable and the number of columns will always be the same.

Thus far, I've been able to figure out the following (below) about cfspreadsheet.

I could put the code below inside a <cfloop> and increment the column and rows with cfif statements to skip the columns I don't want to check. The loop would end with the total numberOfRows CF variable that I have, but I imagine there's a better way to do this using a query.

Can I do this in a query? If so, how?

<cfspreadsheet
  action="read" 
  format = "html"
  src="#SESSION.theFile#"
  name= "test"
  rows = "3"
  columns = "6"
  >


<cfoutput>
   #test#
</cfoutput>
6
  • 1
    CFSpreadsheet can return the results in several format. To work with a query object, you need to use the query attribute, not format=html. Once you have a query, you can filter it using a QoQ. Commented Feb 15, 2014 at 2:57
  • Once I have used the query attribute, how do I execute a query on that query variable? Commented Feb 15, 2014 at 20:13
  • 1
    Use a QoQ. See the previous link. Though cfdump the query variable first to see and understand the query columns you can access. Commented Feb 15, 2014 at 20:16
  • I see the dump file with all the columns. Commented Feb 15, 2014 at 20:36
  • @Leigh please place this as an answer, so I can mark it answered. Commented Feb 15, 2014 at 20:50

2 Answers 2

1

(From comments...)

CFSpreadsheet can return the results in several format. To work with a query object, you need to use the query attribute, not format=html. Once you have a query, you can filter it using a QoQ. CFDump the query variable first to see and understand the query columns you can access.

Sign up to request clarification or add additional context in comments.

Comments

0

You can do things like

<cfspreadsheet action="read" src="#theFile#" sheetname="courses" 
    name="spreadsheetData"> 
<cfdump var="#speadsheetData#">

Adapted from http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec17cba-7f87.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.