comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: import Excel file
Date: Tue, 15 Jun 2004 07:51:18 +0200
Date: 2004-06-15T07:51:18+02:00	[thread overview]
Message-ID: <3232546.XtNgOWSx3K@linux1.krischik.com> (raw)
In-Reply-To: cakjm3$tk1$01$1@news.t-online.com

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




      parent reply	other threads:[~2004-06-15  5:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]
replies disabled

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