You know with the amount of development work you are doing on excel, you
could go to your boss and would have a great excuse to upgrade to the latest
version of ColdFusion. Because all the latest tags for excel I would bet
with the time saved in development would actually pay for the license.




On Wed, Sep 14, 2011 at 12:12 AM, Mo Lay <[email protected]> wrote:

>
> Hi Peers,
> i am trying to use the code i found in one of or CF expert on how to return
> an excel sheet to a query but i am not able to run it ...any help will be
> appreciated
> : we should call that function : getExcelSheet("filename,sheetname)
> i am not getting anything
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title>Untitled Document</title>
>
>
> </head>
>
> <body>
>
> <cffunction name= "getExcelSheet" access= "public" output= "false"
> returntype= "query" >
> <cfargument name= "filename" required= "true" type="string" />
> <cfargument name= "sheetName" required= "true" type="string" />
> <cfscript>
> var c = "";
> var stmnt = "";
> var rs = "";
> var sql = "Select * from [#sheetName#$]" ;
> var myQuery = "";
> arguments.filename = expandPath(arguments.filename);
> if(len(trim(arguments.filename)) and fileExists(arguments.filename)){
> try{
> CreateObject( "java","java.lang.Class" ).forName(
> "sun.jdbc.odbc.JdbcOdbcDriver" );
> c =
> CreateObject( "java","java.sql.DriverManager" ).getConnection(
> "jdbcdbcriver={Microsoft Excel Driver
> (*.xls)};DBQ=" & arguments.filename );
> stmnt = c.createStatement();
> rs = stmnt.executeQuery(sql);
> myQuery = CreateObject('java','coldfusion.sql.QueryTable').init(rs);
> }catch(any e){
> // e r r o r - h a n d l i n g c o d e
> }
> }
> return myQuery;
> </cfscript>
> </cffunction>
>
> <cfform name="tabform">
> <input type="button" onchange="getExcelSheet("exercices.xls","Pull")" />
> </cfform>
>
>
> </body>
> </html>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:5591
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to