From: "Andrew" <andrew@carroll-tech.net>
To: <comp.lang.ada@ada-france.org>
Subject: excel files
Date: Wed, 6 Oct 2004 13:56:58 -0600
Date: 2004-10-06T13:56:58-06:00 [thread overview]
Message-ID: <mailman.224.1097091415.390.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: 20041006132018.833134C40CC@lovelace.ada-france.org
> ------------------------------
> From: Chris Humphries <chris@unixfu.net>
> Subject: Re: excel files
[snip]
> Does anyone have any portable Ada code to offer for parsing excel
files?
> I am a newbie to COM and MFC (well knew it about 6 years ago), and
> do not understand how to go about using ODBC or GNATCOM to do the
> suggested solutions to this problem. Can someone post some code
showing
> how to do this, please :)
[snip]
> ------------------------------
Well, it's not in Ada but this might give you an idea of how to connect
via ODBC.
This is an Active Server Page.
============ code below ===============
<!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
Files\system\ado\msado15.dll" -->
<html>
<head>
</head>
<body>
<% @Language = "JavaScript" %>
<%
/*
* The provider is the path to the excel file. The path provided here
is a relative path.
* It is later combined with a call to Server.MapPath to generate the
absolute path.
*/
var provider = "\data\\NameOfExcelFile.xls";
/*
* Our connection information.
*/
var cn = "Driver={Microsoft Excel Driver (*.xls)}; DBQ=" +
Server.MapPath(provider);
/*
* Our recordset object to manipulate contents of the provider.
* We are using ADODB, the connection is an ODBC connection.
*/
var objRecordSet = Server.CreateObject("ADODB.Recordset");
/*
* Gives me the columns from the database.
* Cheese is a named region in the spreadsheet. To get a whole sheet
* we would have to use $Sheet# instead of Cheese.
*/
SQL = "SELECT * FROM Cheese";
objRecordSet.Open(SQL, cn);
/*
* Just output name=value pairs within the recordset. one per line.
*/
while(!objRecordSet.EOF){
objFields = objRecordSet.Fields;
for(i=0; i < objFields.Count; i++){
Response.write(objFields.Item(i).Name+ " = "
+objFields.Item(i).Value+"<br>");
}
Response.write("<br>");
objRecordSet.MoveNext();
}
/*
* Don't forget to close the objects
*/
if(objRecordSet.State != adStateClosed){
objRecordSet.close();
}
%>
</body>
============ end code ================
Andrew Carroll
Carroll-Tech
720-273-6814
andrew@carroll-tech.net
next parent reply other threads:[~2004-10-06 19:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20041006132018.833134C40CC@lovelace.ada-france.org>
2004-10-06 19:56 ` Andrew [this message]
[not found] <20041006203015.B3B864C40D1@lovelace.ada-france.org>
2004-10-06 21:58 ` excel files Andrew
[not found] <20041005193515.6C38A4C409F@lovelace.ada-france.org>
2004-10-06 9:52 ` Andrew
2004-10-06 10:24 ` stephane richard
2004-10-06 11:58 ` Chris Humphries
2004-10-06 16:27 ` Warren W. Gay VE3WWG
2004-10-06 17:17 ` Chris Humphries
[not found] <20041005034017.9E75B4C4137@lovelace.ada-france.org>
2004-10-05 6:49 ` Andrew
2004-10-05 21:37 ` David Botton
2004-10-04 19:16 Alexandre Devaure
2004-10-04 19:42 ` stephane richard
2004-10-04 20:02 ` Chris Humphries
2004-10-05 0:29 ` Jeffrey Carter
2004-10-05 1:20 ` Stephen Leake
2004-10-04 20:42 ` Martin Dowie
2004-10-04 22:20 ` Jeff C r e e.m
2004-10-05 7:45 ` Georg Bauhaus
2004-10-05 12:32 ` Chris Humphries
2004-10-05 14:16 ` David Botton
2004-10-04 21:40 ` tmoran
2004-10-05 6:30 ` Pascal Obry
2004-10-05 17:31 ` tmoran
2004-10-05 19:00 ` Alexandre Devaure
2004-10-05 19:02 ` Pascal Obry
2004-10-05 0:55 ` David Botton
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox