Question

Parsing an Excel Sheet for a particular format and then send out an email

Asked by: hdharkar

Hello,

I have never done Parsing with Coldfusion.Could someone please direct me to how to parse an excel sheet.There is a particular column where there are machine names and I am looking for a particular format and if there then an email will be sent out.

Thanks
hd

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2006-09-25 at 10:58:04ID22001882
Tags

excel

Topic

ColdFusion Application Server

Participating Experts
3
Points
500
Comments
20

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. par file
    Waht is a file with .par used for and what does this extension mean? Can I list the parameters for import in a .par file and use this file in imp, like imp file=filename.par Please suggest.
  2. PAR Protocol
    How has the PAR Protocol been extended for use in the Internet?
  3. Converting from PERL to Executable using PAR
    I have a PERL script that begins with the following: use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; When I convert my PERL script to an executable using pp -o file.exe file.pl, there is no problem. But, when I run file.exe I receive the following pop-...
  4. What does the /par in a .bat file mean?
    I am learning to do batch files, and came across this /par in my .bat file. I dont know really how it got there, as I was just manually creating the batch. I did just install easy batch creator, but I didnt use that prog. Anyway here is the code that I have in my batch, but ...
  5. Is pixel aspect ratio (PAR) a property of H.264 video …
    I was wondering, if I want to encode a video (most likely H.264 in MP4 container) with non-square pixels, is the PAR (Pixel Aspect Ratio) something specified in the MP4 container or in the H.264 video stream itself, and can it be changed without re-encoding? And using what ap...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: shooksmPosted on 2006-09-25 at 11:24:28ID: 17594777

If there is going to be a single user uploading the document, it would be easier to setup a DSN pointing to a known location that you will store the excel file when the user uploads it.  First, create a blank XLS file in the location you are going to allow the user to stick the file in.  Maybe something like wwwroot\excelupload\temp.xls.  I would then create a system DSN for the excel file via the ODBC Data Source Administrator.  In Cold Fusion Administrator add an ODBC Socket Datasource to your System DSN.  Now you can query directly from the uploaded file using standard CFQUERYs.  The first thing I would do is upload an actual version of the file then run the following SQL in a CFQUERY and dump the recordset to see the columns:

SELECT * FROM [Sheet1$]

 

by: JeffHowdenPosted on 2006-09-25 at 14:48:43ID: 17596682

Do NOT go the DSN route if you want to have any sanity left.  Find yourself a third-party tool that parses Excel files into query data.  There are several.  If you're running CF6.1 or higher then I'd recommend CFX_Excel from MasRizal.com.  No, I don't work for them, but have used it on several projects and am extremely satisfied with the results.

http://www.masrizal.com/index.cfm?fuseaction=idea.download_detail&ProductID=cfx_excel

 

by: dgrafxPosted on 2006-09-26 at 03:53:13ID: 17599871

also, here is some sql that will do what you need.
SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=#pathtoyourxlssheet#;HDR=YES', 'SELECT * FROM [Sheet1$]')
order by whatever
I've only used it on sql server.
also, the sql server instance needs permission to execute this.
If you get:
[Macromedia][SQLServer JDBC Driver][SQLServer]Ad hoc access to OLE DB provider 'Microsoft.Jet.OLEDB.4.0' has been denied. You must access this provider through a linked server.
Then look at this article: http://support.microsoft.com/default.aspx?scid=kb;en-us;327489

Also here is another custom tag you can use:
<cfx_Excel2Query
http://www.emerle.net/programming/display.cfm/t/cfx_excel2query

 

by: hdharkarPosted on 2006-09-26 at 11:33:19ID: 17604115

I won't be able to use paid ones,I tried using the trial version of <cfx_Excel2Query  but it is somehow not registering  on my server.

Also can u tell me how will i call the columnames here,as i have to query one particular column name and if the criteria is met I will send an email.


SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=#pathtoyourxlssheet#;HDR=YES', 'SELECT * FROM [Sheet1$]')


Thanks
hd

 

by: dgrafxPosted on 2006-09-26 at 11:50:38ID: 17604287

SELECT catid, catname, etc
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=#pathtoyourxlssheet#;HDR=YES', 'SELECT * FROM [Sheet1$]')

 ya know that cfx_excel2query is a java cfx - so after creating it manually (I had to create it manually on one server cause it wouldn't register) you need to set the java class path in jvm.config or install the cfx into an existing class path

 

by: hdharkarPosted on 2006-09-27 at 07:56:58ID: 17610827

Hi ,

I tried putting the above query in cfquery then it gave me an error to put in some more attributes.So I then created a dsn to the excel sheet(first in odbc and then in cfadmin) but still its not connecting to the excel sheet and querying it.
this is the code that i put in.The esdexcel is pointing to list.xls too.

<cfquery name="hello" datasource="esdexcel">
      SELECT computername
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=E:\Webs\list.xls;HDR=YES', 'SELECT * FROM [Sheet1$]')
      </cfquery>
            <cfoutput>  
            #hello.computername#
            
            </cfoutput>

Thanks
HD

 

by: dgrafxPosted on 2006-09-27 at 08:26:24ID: 17611129

your datasource needs to be a sql datasource - not an excel datasource - just use a datasource you already have setup.
just do select * to start so you can see whats up.

post the error you get.

 

by: hdharkarPosted on 2006-09-27 at 09:55:28ID: 17611899

Earlier I was getting the Microsoft Error that you mentioned earlier so I followed the procedure but now it gives me a different error


Error Executing Database Query.  
[Macromedia][SQLServer JDBC Driver][SQLServer]OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider did not give any information about the error.  
 
The error occurred in E:\Webs\excelscan_action.cfm: line 63
 
61 : </cfoutput>
62 :
63 :       <cfquery name="hello" datasource="exesd">
64 :       SELECT *
65 : FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=E:\Webs\excel\list.xls;HDR=YES', 'SELECT * FROM [Sheet1$]')
 

--------------------------------------------------------------------------------
 
SQL    SELECT computername FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=E:\Webs\excel\;HDR=YES', 'SELECT * FROM [Sheet1$]')  
DATASOURCE   altirisesd
VENDORERRORCODE   7399
SQLSTATE   HY000
 

 

by: dgrafxPosted on 2006-09-27 at 10:14:09ID: 17612067

are you sure the file E:\Webs\excel\list.xls is correct?
are you sure the datasource is correct : at one point you have exesd and the error says altirisesd
which one is it?
does this server have the 'Microsoft.Jet.OLEDB' driver installed?
is this shared or your own server you control?

 

by: hdharkarPosted on 2006-09-27 at 10:55:43ID: 17612388

The correct datasource is altirisesd.I do not own the server but I do have admin rights on it.The file is also correct.

But I am not sure about the datasource part.Because this datasource is not pointing to the excel sheet , the datasource is for my sql server and as you mentioned earlier I used this one rather than the one for the excel dsn.
So I dont get it as to how will it work with this datasource.Also the cfoutput seems to be a amiss as how will the code detect that the first row are fieldnames when we have not specified them.

Thanks
HD

 

by: dgrafxPosted on 2006-09-27 at 11:13:22ID: 17612514

yes thats correct - you use your usual sql server datasource - as long as it is registered and is a valid datasource.
now does your sheet have a Sheet1 ?
if not - whatever the sheet you want to read would go where the Sheet1$ goes - you need the $ after the sheet name.

<cfquery datasource="altirisesd" name="XLSData">
SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=E:\Webs\excel\list.xls;HDR=YES', 'SELECT * FROM [Sheet1$]')
</cfquery>
<cfdump var="#XLSData#">

If this doesn't work -
is MSDTC enabled on your server?
does sql server have service pack at least 3?
is this sql server 2000?
try this:
select *
FROM OpenRowSet('MSDASQL','Driver=Microsoft Excel Driver (*.xls);
 DBQ=E:\Webs\excel\list.xls', 'SELECT * FROM [Sheet1$]')


 

by: hdharkarPosted on 2006-09-27 at 12:00:51ID: 17613146

Same kind of error.Also everything that you mentioned , my server is compatible to it.

Error Executing Database Query.  

[Macromedia][SQLServer JDBC Driver][SQLServer]OLE DB provider 'MSDASQL' reported an error.


Thanks
HD

 

by: dgrafxPosted on 2006-09-27 at 12:49:21ID: 17613487

go with custom tag ...

 

by: hdharkarPosted on 2006-09-28 at 07:25:26ID: 17619536

Hi dgrafx,

Thankyou for all your help.I did use the custom tag and its finally working on my server but as it is a trial version,I have been asked to use this code,and it will return only 10 rows.
<cfx_excel2query
      file="E:\Webs\excel\list.xls""
      firstRowIsHeader=1
      nodates
      r_qResults="results">

presently I am gett ing this error.Also I want to query the entire sheet and if I find one hit according to my query then I would need to send out an email.But where should I query in this tag,as this will give me the ten rows only,so does that mean if my criteria is not met in the first ten rows then this tag is not useful for me.

Variable R_QRESULTS is undefined.  
 
 
The error occurred in E:\Webs\admin\excelscan_action.cfm: line 67
 
65 :       r_qResults="results">
66 :       
67 :       <cfoutput>  #r_qResults#    </cfoutput>
68 :             
69 :   <hr width="670" align="left">
 
Thanks
HD

 

by: dgrafxPosted on 2006-09-28 at 07:29:48ID: 17619580

the 10 rows is the limitation of the trial.
the full ver only costs $30 bucks

 

by: hdharkarPosted on 2006-09-28 at 07:31:34ID: 17619602

I finally got the 10 rows ,and the above error that I mentioned is gone by using cfdump but now the question remains,that how do I query the entire sheet.I am not interested in showing 10 rows,I just want one hit according to my sql query to send out an email...Any suggestions?.
Thanks
HD

 

by: hdharkarPosted on 2006-09-28 at 07:39:35ID: 17619672

Thanks dgrafx.I guess I need to find out now whether my company will pay for this product.
Thanks
HD

 

by: dgrafxPosted on 2006-09-28 at 07:41:05ID: 17619686

where is your "name" param?
maybe the trial is different or different version but on the one server where I needed to use it I do:
<cfx_Excel2Query
name="XLSData"
file="#filelocation##cffile.serverfile#"
headerRow="1"
firstRowIsHeader="1">

Then - what this is is a query. You treat it like you would any query.
<cfset cList="">
<cfloop query="XLSData">
     <cfif computername is "the_ones_you_are_looking_for">
          <cfset cList=ListAppend(cList,computername)>
     </cfif>
</cfloop>
<cfif listlen(cList)>
<cfmail from=et cetera>
#replace(cList,","," and ","all")# are in this excel sheet
</cfmail>
</cfif>

 

by: hdharkarPosted on 2006-09-28 at 07:56:25ID: 17619819

I tried it,but it says that name and headerrow are unknown attributes.So I guess they do have blocked it for the trial version.And if I use  r_qResults="results"> it checks only in the first 10 rows :(

Thanks
HD

 

by: dgrafxPosted on 2006-09-28 at 08:03:34ID: 17619879

I see.
All I can say is that the full version works really well.
The only difficulty I had was the auto install didn't work.

Good luck ...

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...