comp.lang.ada
 help / color / mirror / Atom feed
* import Excel file
@ 2004-06-14 16:32 Tanker
  2004-06-14 17:36 ` Georg Bauhaus
  2004-06-15  5:51 ` Martin Krischik
  0 siblings, 2 replies; 8+ messages in thread
From: Tanker @ 2004-06-14 16:32 UTC (permalink / raw)


Hi,

I want to import data from an ms exel file in my program. Can someone give
me a hint how I can realize that. I already tried to read the exel file as a
text_io and sequential_Io file but it's not possible as Text_IO 'cause it
must be a sequential_IO (or direct_IO) file. The problem with the
sequential_IO is, that i can't figure out how the form and substance of the
file looks like (is it a record, what kind of record(contents)?)

Thanx in advance
Flo





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: import Excel file
  2004-06-14 16:32 import Excel file Tanker
@ 2004-06-14 17:36 ` Georg Bauhaus
  2004-06-14 18:18   ` tmoran
                     ` (2 more replies)
  2004-06-15  5:51 ` Martin Krischik
  1 sibling, 3 replies; 8+ messages in thread
From: Georg Bauhaus @ 2004-06-14 17:36 UTC (permalink / raw)


Tanker <Tanker93@hotmail.com> wrote:
: Hi,
: 
: I want to import data from an ms exel file in my program. Can someone give
: me a hint how I can realize that. I already tried to read the exel file as a
: text_io and sequential_Io file but it's not possible as Text_IO 'cause it
: must be a sequential_IO (or direct_IO) file. The problem with the
: sequential_IO is, that i can't figure out how the form and substance of the
: file looks like (is it a record, what kind of record(contents)?)

Just reading in an Excel file isn't probably promising, because
it is not a text file. The structure of the binary data isn't
usually known. However, you could try exporting sheets to CSVs,
and read these with less effort.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: import Excel file
  2004-06-14 17:36 ` Georg Bauhaus
@ 2004-06-14 18:18   ` tmoran
  2004-06-14 18:23   ` Tanker
  2004-06-14 18:23   ` Björn Persson
  2 siblings, 0 replies; 8+ messages in thread
From: tmoran @ 2004-06-14 18:18 UTC (permalink / raw)


>it is not a text file. The structure of the binary data isn't
>usually known. However, you could try exporting sheets to CSVs,
>and read these with less effort.
  Just run Excel and look at all the different choices for exporting
data.  With simple numbers, Comma Separated Values is simple, but
it gets a little nastier with text, especially text with commas and
quotes.  Or you can read the data by using an Ada database binding
and using the Excel data as a database source.  There's also SYLK
files, which are text and contain the formulas and formats as well
as the data.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: import Excel file
  2004-06-14 17:36 ` Georg Bauhaus
  2004-06-14 18:18   ` tmoran
@ 2004-06-14 18:23   ` Tanker
  2004-06-15  1:11     ` Jeff C,
  2004-06-14 18:23   ` Björn Persson
  2 siblings, 1 reply; 8+ messages in thread
From: Tanker @ 2004-06-14 18:23 UTC (permalink / raw)


That was my first idea too, but the guy who I'm writing the program for,
thinks that is a good thing to import an excel file directly without the
step of making an csv file. A friend told me today, that there must be a ms
tool for C++ (Ms Visual C++) that can sort out the relevant information from
the excel file. I could bind the C++ code in my ada programm and use the
excel infos.
If it's too difficult to do, I will convince him that it must work with the
cvs transformation.

Thanks for your help!!!

"Georg Bauhaus" <sb463ba@l1-hrz.uni-duisburg.de> schrieb im Newsbeitrag
news:caknnm$kvt$3@a1-hrz.uni-duisburg.de...
> Tanker <Tanker93@hotmail.com> wrote:
> : Hi,
> :
> : I want to import data from an ms exel file in my program. Can someone
give
> : me a hint how I can realize that. I already tried to read the exel file
as a
> : text_io and sequential_Io file but it's not possible as Text_IO 'cause
it
> : must be a sequential_IO (or direct_IO) file. The problem with the
> : sequential_IO is, that i can't figure out how the form and substance of
the
> : file looks like (is it a record, what kind of record(contents)?)
>
> Just reading in an Excel file isn't probably promising, because
> it is not a text file. The structure of the binary data isn't
> usually known. However, you could try exporting sheets to CSVs,
> and read these with less effort.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: import Excel file
  2004-06-14 17:36 ` Georg Bauhaus
  2004-06-14 18:18   ` tmoran
  2004-06-14 18:23   ` Tanker
@ 2004-06-14 18:23   ` Björn Persson
  2 siblings, 0 replies; 8+ messages in thread
From: Björn Persson @ 2004-06-14 18:23 UTC (permalink / raw)


Georg Bauhaus wrote:

> Just reading in an Excel file isn't probably promising, because
> it is not a text file. The structure of the binary data isn't
> usually known.

At least Microsoft tries to keep it secret. The Openoffice developers 
seem to have figured it out fairly well, so there's always the 
possibility of looking at their code. It's probably very hairy.

> However, you could try exporting sheets to CSVs,
> and read these with less effort.

Personally I'd prefer TSV (tab-separated) if Excel can produce that.

-- 
Björn Persson

jor ers @sv ge.
b n_p son eri nu




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: import Excel file
  2004-06-14 18:23   ` Tanker
@ 2004-06-15  1:11     ` Jeff C,
  2004-06-15 21:24       ` Pascal Obry
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff C, @ 2004-06-15  1:11 UTC (permalink / raw)



"Tanker" <Tanker93@hotmail.com> wrote in message
news:cakq5f$cot$05$1@news.t-online.com...
> That was my first idea too, but the guy who I'm writing the program for,
> thinks that is a good thing to import an excel file directly without the
> step of making an csv file. A friend told me today, that there must be a
ms
> tool for C++ (Ms Visual C++) that can sort out the relevant information
from
> the excel file. I could bind the C++ code in my ada programm and use the
> excel infos.
> If it's too difficult to do, I will convince him that it must work with
the
> cvs transformation.
>

There is already a tool that does it quite well. It is called Excel :)

Seriously, excel (at least older version) could be accessed via COM
libraries. You can auto create
bindings to the excel COM libraries pretty easily using GNATCOM

http://www.adapower.com/gnatcom/index.html

For some things it is really easy to use the COM interface. For others...not
so easy.

Not sure where excel falls.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: import Excel file
  2004-06-14 16:32 import Excel file Tanker
  2004-06-14 17:36 ` Georg Bauhaus
@ 2004-06-15  5:51 ` Martin Krischik
  1 sibling, 0 replies; 8+ messages in thread
From: Martin Krischik @ 2004-06-15  5:51 UTC (permalink / raw)


Tanker wrote:

> Hi,
> 
> I want to import data from an ms exel file in my program. Can someone give
> me a hint how I can realize that. I already tried to read the exel file as
> a text_io and sequential_Io file but it's not possible as Text_IO 'cause
> it must be a sequential_IO (or direct_IO) file. The problem with the
> sequential_IO is, that i can't figure out how the form and substance of
> the file looks like (is it a record, what kind of record(contents)?)

I take it that you have some documentation on the format of excel and that
you are willing to take the effort of reading a binary file.

Since the excel format containts loot of different data the answer are
streams. Ada streams are the File IO to read different types.

An integer is read by:

A : Integer := Integer'Input (My_Stream);

Integer'Read (My_Stream, A);

A X Character String by:

type X_String is new string (1 .. X)

X : X_String := X_String'Input (My_Stream);

X_String'Read (My_Stream, X);

Beware: There is a important difference between 'Read and 'Input: 'Read is
more low level and 'Input more high level. i.E. String'Input expect the
length of the string to be part of the input data - String'Read does not.

However, in the example I have given I used X_String of the defined length X
- since the length is known X_String'Read and X_String'Input should work
the same.

With Regads

Martin

-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: import Excel file
  2004-06-15  1:11     ` Jeff C,
@ 2004-06-15 21:24       ` Pascal Obry
  0 siblings, 0 replies; 8+ messages in thread
From: Pascal Obry @ 2004-06-15 21:24 UTC (permalink / raw)



"Jeff C," <jcreem@yahoo.com> writes:

> Seriously, excel (at least older version) could be accessed via COM
> libraries. You can auto create
> bindings to the excel COM libraries pretty easily using GNATCOM

And via ODBC too.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-06-15 21:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-14 16:32 import Excel file Tanker
2004-06-14 17:36 ` Georg Bauhaus
2004-06-14 18:18   ` tmoran
2004-06-14 18:23   ` Tanker
2004-06-15  1:11     ` Jeff C,
2004-06-15 21:24       ` Pascal Obry
2004-06-14 18:23   ` Björn Persson
2004-06-15  5:51 ` Martin Krischik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox