automatic or scripted export of graphics from gnumeric

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

automatic or scripted export of graphics from gnumeric

John Denker
Hi Folks --

By way of background and by way of analogy:  I have a great many .svg files.
I have scripts and makefiles that automagically convert them to .pdf and .png
format if/whenever needed.  This relies on the script-friendly export features
of the inkscape command-line interface.  This is an important part of the project
workflow.

I also have a great many .gnumeric files containing graphs.

Desired behavior:  It would be reeeeally nice to export those graphs in .pdf
or .png or whatever format, in a way that could be *automated* as part of the
project workflow.

Observed behavior:  Right now, to export the graphics, I have to open each
.gnumeric file and do a bunch of work by hand.  In particular, I cannot
simply do
     git pull ; make
and expect the graphs images to be up-to-date.

Question:  Is there a way to automate this?  I'm pretty sure ssconvert doesn't
know how to do it.  Is there some other tool?

If not, how hard would it be to implement this, as part of ssconvert or otherwise?

I can think of several reasons why it wouldn't be easy, but it doesn't sound
impossible, and it would be reeeeeally nice.
_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: automatic or scripted export of graphics from gnumeric

Jean Bréfort-3
Hi John,

There is currently no script or program doing that but I suppose it
would be not so hard to implement either in C or using a scripting
language and introspection. Probably a few hours or work, depending of
the wanted options.

Regards,
Jean

Le jeudi 12 janvier 2017 à 23:05 -0700, John Denker a écrit :

> Hi Folks --
>
> By way of background and by way of analogy:  I have a great many .svg
> files.
> I have scripts and makefiles that automagically convert them to .pdf
> and .png
> format if/whenever needed.  This relies on the script-friendly export
> features
> of the inkscape command-line interface.  This is an important part of
> the project
> workflow.
>
> I also have a great many .gnumeric files containing graphs.
>
> Desired behavior:  It would be reeeeally nice to export those graphs
> in .pdf
> or .png or whatever format, in a way that could be *automated* as
> part of the
> project workflow.
>
> Observed behavior:  Right now, to export the graphics, I have to open
> each
> .gnumeric file and do a bunch of work by hand.  In particular, I
> cannot
> simply do
>      git pull ; make
> and expect the graphs images to be up-to-date.
>
> Question:  Is there a way to automate this?  I'm pretty sure
> ssconvert doesn't
> know how to do it.  Is there some other tool?
>
> If not, how hard would it be to implement this, as part of ssconvert
> or otherwise?
>
> I can think of several reasons why it wouldn't be easy, but it
> doesn't sound
> impossible, and it would be reeeeeally nice.
> _______________________________________________
> gnumeric-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gnumeric-list

_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: automatic or scripted export of graphics from gnumeric

John Denker
On 01/13/2017 02:38 AM, Jean Brefort wrote:

> There is currently no script or program doing that but I suppose it
> would be not so hard to implement either in C or using a scripting
> language and introspection. Probably a few hours or work, depending of
> the wanted options.


I spent a couple hours already looking into this.  The closest I
could come to a working model using a scripting language was this:
  https://mail.gnome.org/archives/gnumeric-list/2015-November/msg00001.html

which doesn't actually work.  When I try it using python (aka
python2.7) I observe:

>> Traceback (most recent call last):
>>   File "./gnumeric-introspection", line 4, in <module>
>>     gi.require_version('GOffice','0.10')
>> AttributeError: 'module' object has no attribute 'require_version'

or using python3 (aka python3.5) it doesn't even get that far.
I observe:

>> Traceback (most recent call last):
>>   File "./gnumeric-introspection", line 3, in <module>
>>     import gi
>>   File "/usr/local/lib/python3.5/dist-packages/gi/__init__.py", line 39
>>     print url
>>             ^
>> SyntaxError: Missing parentheses in call to 'print'



Also, the closest I could come to useful documentation was this:
  https://lazka.github.io/pgi-docs/Gnm-1.12/classes.html
  https://lazka.github.io/pgi-docs/Gnm-1.12/classes/Workbook.html
  etc.

which AFAICT makes no mention of saving a graph, or even inspecting
the structures within a graph.

-- Are there any working examples of gnumeric introspection that
   could be used as a model?
-- Where should one look for documentation?
-- Or would it be better to give up on introspection and just write
   in C, using ssconvert.c as a model?


=======================

Also, given a workbook with multiple sheets and multiple graphs per
sheet, what is the proper way to identify a particular graph?  In
.svg format, the objects have id="whatever" attributes, but AFAICT
in .gnumeric format they don't.

I suppose one could add a title to each graph, using a zero-point
font, and use that for identification.  Is there a better way?

This may be related to the code in ssconvert.c where it says:
>> * HACK: (bug 694408).
>> *
>> * We don't have a good way of specifying the
>> * sheet.
  https://bugzilla.gnome.org/show_bug.cgi?id=694408

_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: automatic or scripted export of graphics from gnumeric

Jean Bréfort-3
Le vendredi 13 janvier 2017 à 06:37 -0700, John Denker a écrit :

> On 01/13/2017 02:38 AM, Jean Brefort wrote:
>
> > There is currently no script or program doing that but I suppose it
> > would be not so hard to implement either in C or using a scripting
> > language and introspection. Probably a few hours or work, depending
> > of
> > the wanted options.
>
>
> I spent a couple hours already looking into this.  The closest I
> could come to a working model using a scripting language was this:
>   https://mail.gnome.org/archives/gnumeric-list/2015-November/msg0000
> 1.html
>
> which doesn't actually work.  When I try it using python (aka
> python2.7) I observe:
>
> > > Traceback (most recent call last):
> > >   File "./gnumeric-introspection", line 4, in <module>
> > >     gi.require_version('GOffice','0.10')
> > > AttributeError: 'module' object has no attribute
> > > 'require_version'

You might have a too old GObject Introspection version, try without
this line.

> or using python3 (aka python3.5) it doesn't even get that far.
> I observe:
>
> > > Traceback (most recent call last):
> > >   File "./gnumeric-introspection", line 3, in <module>
> > >     import gi
> > >   File "/usr/local/lib/python3.5/dist-packages/gi/__init__.py",
> > > line 39
> > >     print url
> > >             ^
> > > SyntaxError: Missing parentheses in call to 'print'
>
Weird.

>
> Also, the closest I could come to useful documentation was this:
>   https://lazka.github.io/pgi-docs/Gnm-1.12/classes.html
>   https://lazka.github.io/pgi-docs/Gnm-1.12/classes/Workbook.html
>   etc.

A good start.

> which AFAICT makes no mention of saving a graph, or even inspecting
> the structures within a graph.

You must get the list of graphs using Sheet::objects_get()

> -- Are there any working examples of gnumeric introspection that
>    could be used as a model?
> -- Where should one look for documentation?
> -- Or would it be better to give up on introspection and just write
>    in C, using ssconvert.c as a model?

May be C might be easier, not sure.

> =======================
>
> Also, given a workbook with multiple sheets and multiple graphs per
> sheet, what is the proper way to identify a particular graph?  In
> .svg format, the objects have id="whatever" attributes, but AFAICT
> in .gnumeric format they don't.

There is no identifier for graphs or any other object for now. May be
in next major version.

> I suppose one could add a title to each graph, using a zero-point
> font, and use that for identification.  Is there a better way?
>
> This may be related to the code in ssconvert.c where it says:
> > > * HACK: (bug 694408).
> > > *
> > > * We don't have a good way of specifying the
> > > * sheet.
>
>   https://bugzilla.gnome.org/show_bug.cgi?id=694408
>
> _______________________________________________
> gnumeric-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gnumeric-list

_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: automatic or scripted export of graphics from gnumeric

John Denker
On 01/13/2017 08:38 AM, Jean Brefort wrote:

> You might have a too old GObject Introspection version,

Where/how should one obtain an up-to-date version of the python module
suitable for gnumeric introspection?
-- pip gi downloads some irrelevant "gist" module
-- pip python-gi says "No matching distribution found"
-- ditto for pip3


> You must get the list of graphs using Sheet::objects_get()

Yes, but what then?  As I said previously, AFAICT the documentation gives
no hint as to how to save the graph, or even how to look at the properties
within the graph object.

Are there any working examples of gnumeric introspection?

_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: automatic or scripted export of graphics from gnumeric

Jean Bréfort-3
Le vendredi 13 janvier 2017 à 11:35 -0700, John Denker a écrit :

> On 01/13/2017 08:38 AM, Jean Brefort wrote:
>
> > You might have a too old GObject Introspection version,
>
> Where/how should one obtain an up-to-date version of the python
> module
> suitable for gnumeric introspection?
> -- pip gi downloads some irrelevant "gist" module
> -- pip python-gi says "No matching distribution found"
> -- ditto for pip3

I don't know what is pip. Ask on your distribution forum. Note that
things can work with older versions, you just don't need to require a
version, just use:
>>>from gi.repository import GOffice
>>>from gi.repository import Gnm


> > You must get the list of graphs using Sheet::objects_get()
>
> Yes, but what then?  As I said previously, AFAICT the documentation
> gives
> no hint as to how to save the graph, or even how to look at the
> properties
> within the graph object.

You need to use the export_image() method for each graph.

> Are there any working examples of gnumeric introspection?

No serious one for now.

_______________________________________________
gnumeric-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gnumeric-list
Loading...