Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

He's dead, Jim.


devel / comp.lang.ada / Re: Ada interface to Excel file

SubjectAuthor
* Ada interface to Excel fileAdaMagica
+* Re: Ada interface to Excel fileJeffrey R.Carter
|`* Re: Ada interface to Excel fileGautier write-only address
| `* Re: Ada interface to Excel fileJeffrey R.Carter
|  `- Re: Ada interface to Excel fileAdaMagica
+- Re: Ada interface to Excel fileDmitry A. Kazakov
`* Re: Ada interface to Excel fileGautier write-only address
 `- Re: Ada interface to Excel fileBjörn Lundin

1
Ada interface to Excel file

<fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9518&group=comp.lang.ada#9518

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:130c:b0:3ef:3204:5158 with SMTP id v12-20020a05622a130c00b003ef32045158mr1368122qtk.7.1681925771074;
Wed, 19 Apr 2023 10:36:11 -0700 (PDT)
X-Received: by 2002:a25:6f86:0:b0:b92:3962:13d4 with SMTP id
k128-20020a256f86000000b00b92396213d4mr285262ybc.11.1681925770861; Wed, 19
Apr 2023 10:36:10 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 19 Apr 2023 10:36:10 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=54.93.231.212; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 54.93.231.212
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com>
Subject: Ada interface to Excel file
From: christ-usch.grein@t-online.de (AdaMagica)
Injection-Date: Wed, 19 Apr 2023 17:36:11 +0000
Content-Type: text/plain; charset="UTF-8"
 by: AdaMagica - Wed, 19 Apr 2023 17:36 UTC

I create Ada code from an Excel file. For this, I first manually export the file to csv format. The code generator works on the csv file.
I'd like to automate this first step by including the export into the code generator.

I guess there is a C interface for Excel. I only just need the export functionality, not a full interface.
However, being illiterate in C, I'd further welcome help on the way to define an Ada interface to this C code.

Can anyone help, please? Thanx a lot.

Christoph

Re: Ada interface to Excel file

<u1pbha$98t$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9519&group=comp.lang.ada#9519

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Ada interface to Excel file
Date: Wed, 19 Apr 2023 20:22:34 +0200
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <u1pbha$98t$1@dont-email.me>
References: <fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 19 Apr 2023 18:22:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="df5fdb0d7183934a724b4dddc64987ce";
logging-data="9501"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+K1py7D1+PkTTLCCn0DoJHcSg2PzhGejk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Cancel-Lock: sha1:3KBiOrOdsxbA5gBGRn/RVUX2K0Q=
Content-Language: en-US
In-Reply-To: <fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com>
 by: Jeffrey R.Carter - Wed, 19 Apr 2023 18:22 UTC

G. de Montmollin has an Ada Excel writer, an Ada pkg for writing Excel files
(https://sourceforge.net/projects/excel-writer/). Presumably it could be
modified to read them.

--
Jeff Carter
"I spun around, and there I was, face to face with a
six-year-old kid. Well, I just threw my guns down and
walked away. Little bastard shot me in the ass."
Blazing Saddles
40

Re: Ada interface to Excel file

<u1r01s$h72t$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9522&group=comp.lang.ada#9522

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Ada interface to Excel file
Date: Thu, 20 Apr 2023 11:18:53 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <u1r01s$h72t$1@dont-email.me>
References: <fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Apr 2023 09:18:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="45ff78a558fd0d4bbad5d8d6785e8426";
logging-data="564317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193gl6Ryr85DKWQgDDuP3Lhlss6J2c37wk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Cancel-Lock: sha1:WgWuYco10rDswuUPO6NCTq5SYe8=
Content-Language: en-US
In-Reply-To: <fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com>
 by: Dmitry A. Kazakov - Thu, 20 Apr 2023 09:18 UTC

On 2023-04-19 19:36, AdaMagica wrote:
> I create Ada code from an Excel file. For this, I first manually export the file to csv format. The code generator works on the csv file.
> I'd like to automate this first step by including the export into the code generator.
>
> I guess there is a C interface for Excel. I only just need the export functionality, not a full interface.
> However, being illiterate in C, I'd further welcome help on the way to define an Ada interface to this C code.
>
> Can anyone help, please? Thanx a lot.

AFAIK, Excel has an ODBC driver. So you can simply read/write an Excel
table directly from Ada using ODBC SQL statements.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Ada interface to Excel file

<1205879c-cbef-4a87-b3a5-94f9db91f2f0n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9525&group=comp.lang.ada#9525

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:10b6:b0:74e:2e3:8e24 with SMTP id h22-20020a05620a10b600b0074e02e38e24mr478716qkk.6.1682017720939;
Thu, 20 Apr 2023 12:08:40 -0700 (PDT)
X-Received: by 2002:a81:ac41:0:b0:545:f7cc:f30 with SMTP id
z1-20020a81ac41000000b00545f7cc0f30mr1230895ywj.0.1682017720779; Thu, 20 Apr
2023 12:08:40 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Thu, 20 Apr 2023 12:08:40 -0700 (PDT)
In-Reply-To: <fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a02:1210:2e90:8100:ed16:afa:6e63:c227;
posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG
NNTP-Posting-Host: 2a02:1210:2e90:8100:ed16:afa:6e63:c227
References: <fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1205879c-cbef-4a87-b3a5-94f9db91f2f0n@googlegroups.com>
Subject: Re: Ada interface to Excel file
From: gautier_niouzes@hotmail.com (Gautier write-only address)
Injection-Date: Thu, 20 Apr 2023 19:08:40 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Gautier write-only a - Thu, 20 Apr 2023 19:08 UTC

The simplest way by far is to generate the Ada sources
from within Excel by using VBA (a BASIC with a strong Ada flavour,
but still a BASIC) which is part of Excel.
From Excel, you activate VBA with the Alt-F11 shortcut.

You have "modules" which are just editor files and visible from
everywhere else (you have like implicit "with"'s and "use"'s); you
have functions called "Function" and procedures called "Sub".
You can associate a button in the Excel sheet to a Sub.
You declare each variable with "Dim x As Type".
You can also forget to declare variables, with funny outcomes.
The behavious of the type system around parameter passing is also funny.

You find below a few examples.
Now, if you already have your CSV-to-Ada generator, you can export a CSV; that's also easy with VBA.

G.

[somewhere (some module)]
Sub Generate_for_Production()
Dim anchor As String ' VBA String is Ada's Unbounded_String
' File handles
Dim fh_ada_spec As Integer
Dim fh_ada_body As Integer
...
Open ThisWorkbook.Path & "\src\" & pkg_name & _
".ads" For Output As #fh_ada_spec
...
For Each ws In Worksheets ' Scan all worksheets
For Each r In ws.UsedRange.Rows ' Scan all used rows
anchor = r.Cells(1, 1).Value
If anchor <> "" Then
...
End If
Next r
Next ws
...
Close #fh_ada_spec
End Sub

[somewhere else (perhaps another module)]

Print #fh, "with Ada.Calendar;"
Print #fh, "with Ada.Unchecked_Conversion;"
Print #fh, "with Interfaces;"
Print #fh,
Print #fh, "package " & name & " is"

[somewhere else]

If simple_record Then
Print #fh_ada_spec, " -- Simple record."
Print #fh_ada_spec,
Print #fh_ada_spec, " type Xyz is record -- " & paragraph
Else
Print #fh_ada_spec, " type Xyz is new " & parent_name & _
"Abc with record -- " & paragraph
End If

[somewhere else]

For i = min_row_offset To max_row_offset
' Convert name in cell to Ada name
field = Ada_Name(r.Cells(i, 3).Value)
If field = "" Then
Exit For
End If
amount = r.Cells(i, 6).Value
...
Print #fh_ada_body, " for index in 1 .. " & amount & " loop"
Print #fh_ada_body, " declare"

Re: Ada interface to Excel file

<8536a0ef-e0c1-4c4f-849c-704c2bca035an@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9526&group=comp.lang.ada#9526

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ad4:4e92:0:b0:5ef:4ec7:c70a with SMTP id dy18-20020ad44e92000000b005ef4ec7c70amr420934qvb.1.1682018666464;
Thu, 20 Apr 2023 12:24:26 -0700 (PDT)
X-Received: by 2002:a25:3187:0:b0:b95:3e0b:45b8 with SMTP id
x129-20020a253187000000b00b953e0b45b8mr74315ybx.2.1682018666174; Thu, 20 Apr
2023 12:24:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Thu, 20 Apr 2023 12:24:25 -0700 (PDT)
In-Reply-To: <u1pbha$98t$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a02:1210:2e90:8100:ed16:afa:6e63:c227;
posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG
NNTP-Posting-Host: 2a02:1210:2e90:8100:ed16:afa:6e63:c227
References: <fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com> <u1pbha$98t$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8536a0ef-e0c1-4c4f-849c-704c2bca035an@googlegroups.com>
Subject: Re: Ada interface to Excel file
From: gautier_niouzes@hotmail.com (Gautier write-only address)
Injection-Date: Thu, 20 Apr 2023 19:24:26 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1773
 by: Gautier write-only a - Thu, 20 Apr 2023 19:24 UTC

> G. de Montmollin has an Ada Excel writer, an Ada pkg for writing Excel files
> (https://sourceforge.net/projects/excel-writer/). Presumably it could be
> modified to read them.

Actually, it is a completely different job. Note that it is the case for many formats (think of HTML or XML for instance).

Now, you find in the Excel Writer toolbox a program called biff_dump.adb that supports some early Excel formats and could be extended.
For the current format(s) (.xlsx), you can combine Zip-Ada for the container and XML-Ada for the contents.
Same for the .ods format.

Re: Ada interface to Excel file

<u1s615$nque$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9527&group=comp.lang.ada#9527

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bnl@nowhere.com (Björn Lundin)
Newsgroups: comp.lang.ada
Subject: Re: Ada interface to Excel file
Date: Thu, 20 Apr 2023 22:07:00 +0200
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <u1s615$nque$1@dont-email.me>
References: <fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com>
<1205879c-cbef-4a87-b3a5-94f9db91f2f0n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Apr 2023 20:07:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bde509ba78ac46dea63a281d1bbd1963";
logging-data="781262"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Vd+ro/pebDD54u9atLMd8"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:lVlKdDoPcqYS3TrqrAWnGNjRW4c=
In-Reply-To: <1205879c-cbef-4a87-b3a5-94f9db91f2f0n@googlegroups.com>
Content-Language: en-US
 by: Björn Lundin - Thu, 20 Apr 2023 20:07 UTC

On 2023-04-20 21:08, Gautier write-only address wrote:

> You can also forget to declare variables, with funny outcomes.
I set
option explicit
at the top of the module, which makes it complain if variable not decalared.

Or used to 25 years ago anyway.

option base 1
is good too, to make array index start at 1 instead of 0

VBA - long time ago - but some fond memories

--
/Björn

Re: Ada interface to Excel file

<u1s8fq$hqnj$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9528&group=comp.lang.ada#9528

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Ada interface to Excel file
Date: Thu, 20 Apr 2023 22:48:57 +0200
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <u1s8fq$hqnj$1@dont-email.me>
References: <fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com>
<u1pbha$98t$1@dont-email.me>
<8536a0ef-e0c1-4c4f-849c-704c2bca035an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Apr 2023 20:48:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a93837184130a76ac5f264668ae834fc";
logging-data="584435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1nEfh1ucsC0hNxxbOqHnniz8zge5sY00="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Cancel-Lock: sha1:9Ddvdw2eptw5/DJ7ef5zhZlFiJA=
Content-Language: en-US
In-Reply-To: <8536a0ef-e0c1-4c4f-849c-704c2bca035an@googlegroups.com>
 by: Jeffrey R.Carter - Thu, 20 Apr 2023 20:48 UTC

On 2023-04-20 21:24, Gautier write-only address wrote:
>> G. de Montmollin has an Ada Excel writer, an Ada pkg for writing Excel files
>> (https://sourceforge.net/projects/excel-writer/). Presumably it could be
>> modified to read them.
>
> Actually, it is a completely different job. Note that it is the case for many formats (think of HTML or XML for instance).

"Modified" was a poor choice of words. "Used to figure out how" is more what I
had in mind.

--
Jeff Carter
"If change threatens you, you become conservative
in self-defense. If it thrills you, you become
liberal in self-liberation. ... [T]he Threateneds
are frequently more successful in the short run,
because they always fight dirty. But in the long
run, they always lose, because Thrilled people
learn and thus accomplish more."
Variable Star
220

Re: Ada interface to Excel file

<1ba7c651-c47a-41a4-8d12-05a5470130b4n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9538&group=comp.lang.ada#9538

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5a8c:0:b0:3ef:3b04:b8f1 with SMTP id c12-20020ac85a8c000000b003ef3b04b8f1mr4691803qtc.0.1682331323618;
Mon, 24 Apr 2023 03:15:23 -0700 (PDT)
X-Received: by 2002:a25:7386:0:b0:b8f:578c:4e3a with SMTP id
o128-20020a257386000000b00b8f578c4e3amr4283570ybc.12.1682331323432; Mon, 24
Apr 2023 03:15:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 24 Apr 2023 03:15:23 -0700 (PDT)
In-Reply-To: <u1s8fq$hqnj$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=3.124.206.215; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 3.124.206.215
References: <fb877c1f-9dc3-45ed-af3a-fab90f77d548n@googlegroups.com>
<u1pbha$98t$1@dont-email.me> <8536a0ef-e0c1-4c4f-849c-704c2bca035an@googlegroups.com>
<u1s8fq$hqnj$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1ba7c651-c47a-41a4-8d12-05a5470130b4n@googlegroups.com>
Subject: Re: Ada interface to Excel file
From: christ-usch.grein@t-online.de (AdaMagica)
Injection-Date: Mon, 24 Apr 2023 10:15:23 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1332
 by: AdaMagica - Mon, 24 Apr 2023 10:15 UTC

Thank you all for your replies.
This doesn't look easy so I guess I just leave it as is. Thanx again.
Christoph

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor