comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: Ada Spreadsheet output
Date: Wed, 20 Nov 2013 03:03:45 -0600
Date: 2013-11-20T03:03:45-06:00	[thread overview]
Message-ID: <85d2lvwiku.fsf@stephe-leake.org> (raw)
In-Reply-To: a785a171-41dd-4b9a-b876-b0303d4b9668@googlegroups.com

Serge Mosin <svmosin@gmail.com> writes:

> I need to output simple data, but it has a complex cell structure. 

This sounds like a contradiction to me; can you give an example?

> I beleive, CSV files are similar to using ODBC interface, where I only
> can have simple key-valued files, which is not enough in my situation.

No, CSV files are even simpler; there is no notion of "keys" inherent in
the format.

A CSV file has characters in cells. Each row of cells is separated by a
newline, and within each row, each cell is separated by a comma (or any
other delimiting character).
http://en.wikipedia.org/wiki/Comma-separated_values

The interpretation of the characters in each cell is up to the
spreadsheet program, so the structure can be as complex as needed. In
particular, if you want commas in a cell, the spreadsheet has to define
a quoting syntax. Usually it's easier to use a different delimiter, such
as tab, that is not needed in the cell data.

For example, I just wrote a CSV file in Emacs, by typing the characters:

1,0
2,=A1-B1
3,=A2-B2

Then I opened that file in OpenOffice Calc; the cells starting with "="
were interpreted as formulas, and the spreadsheet display is:

1   0
2   1
3   1

When I examine cell B2, it has the formula =A1-B1. I can then save it in
any format OpenOffice supports. However, if I save it as a CSV, the file
has numbers, not the formulas. That makes sense, because you might be
exporting the results to a plotting program. But it would also make
sense to have an option to export the formulas.

So as far as I can see, any formula in an OpenOffice spreadsheet can be
imported into OpenOffice via a CSV file. 

What else do you need?


The standard OpenOffice file format of ODS supports metadata; cell
formatting styles, color, everything else you can set via the toolbars.
That data is not representable in the CSV. So if you need to import that
data, you'd have to write the ODS format directly. That's a zip of xml
files, and there are Ada libraries that do both, so there is code you
could build on.

The representation of the single cell B3 in the ODS content.xml file
looks like this:

<table:table-cell table:formula="of:=[.A2]-[.B2]"
office:value-type="float" office:value="1">

That should be easy to generate with the GNAT XML/Ada library.

-- 
-- Stephe

  reply	other threads:[~2013-11-20  9:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-17  4:45 Ada Spreadsheet output Serge Mosin
2013-11-17  5:44 ` Jeffrey Carter
2013-11-17  6:43   ` Serge Mosin
2013-11-17 11:17     ` Sebastian Doht
2013-11-18 14:55     ` Stephen Leake
2013-11-19 11:14       ` Serge Mosin
2013-11-20  9:03         ` Stephen Leake [this message]
2013-11-19 11:09 ` Maxim Reznik
replies disabled

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