Making selections before conversion #34

dagwieers opened this Issue Feb 16, 2012 · 12 comments


None yet
9 participants

dagwieers commented Feb 16, 2012

In some cases users would like to make selections before doing the conversion, this could be useful in order to:

  • select a specific sheet in a spreadsheet to convert (currently only the first sheet is converted)
  • select a specific range in a spreadsheet to convert
  • select a specific range of pages to convert

The difficulty here is two-fold:

  • how do we describe the various pieces for doing the selection
  • how do we instruct LibreOffice to perform the description of what the user needs

So a lot of discussion around this is needed to understand the various requirements and implementation bits. Feedback welcome

zonaj commented May 15, 2012

I had a desperate need to export specific sheets from many spreadsheets recently and modified unoconv to do my bidding. I'm not suggesting that this is a good approach for specifying the sheet to convert, but it has really helped me out in a pinch. Below is the patch of what I've done (this is against debian wheezy's unoconv):

>         self.sheet_name = None
<             opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:v',
>             opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:S:T:t:v',
<                  'pipe=', 'port=', 'server=', 'timeout=', 'show', 'stdout',
<                  'template', 'verbose', 'version'] )
>                  'pipe=', 'port=', 'server=', 'timeout=', 'sheet=', 'show',
>                  'stdout', 'template', 'verbose', 'version'] )
>             elif opt in ['-S', '--sheet']:
>                 self.sheet_name = arg
>             if op.sheet_name:
>                 sheets = document.getSheets()
>                 sheets.moveByName(op.sheet_name, 0)

zopa commented Jun 21, 2012

In case it proves useful to anyone in the interim, I've applied zonaj's changes to a fork of unoconv.

No pull request at present, since --sheet='sheet-name' probably isn't the best solution in the long term. It's been quite helpful, however.


dagwieers commented Jun 27, 2012

Yes, it's interesting to see how it's done on a per-sheet basis. But I think we need to have a more general --select option that allows you to specify:

  • page or pagerange
  • sheet or sheetrange
  • sheet+cellranges
  • slides or slideranges

It cannot be that hard.


dagwieers commented Jul 27, 2012

Let me also add, that I prefer a solution that is not limited to spreadsheets. The same is useful for selecting pages or slides during conversions using the same option.


dagwieers commented Sep 12, 2012

Apart from this generic use-case (i.e. making selections before doing the export), there may be more flexible option by allowing people to write plugins/extensions to unoconv that we can maintain separately. unoconv could allow to run such a plugin/extension between the import and export phase where the user can make manipulations (search-and-replace, content-modifications, selections, disabling/enabling options, formatting, ...)

A hint into that direction is available from #40, and apart from the selection functionality that appeals to most users, I would like to implement this plugin/extension mechanism independently. For this I opened a new ticket #84, which in my opinion is more important than any other existing feature request :-)

freewil commented Feb 13, 2014

👍 for this.

I took the @zopa / @zonaj fork and updated it to the current version of master:

tenbits commented Apr 4, 2014

@freewil , thanks - it really works) Why you didn't create the pull request?

freewil commented Apr 4, 2014

Based on the discussion above, it doesn't sound like it would be considered merge-worthy.

@dagwieers If i submit the PR, will you merge it?

I have this need. I am not sure if I really understand whether my need is solved by the above. I want a simple unoconv command line to convert ALL slides to some image format to my output directory. The above seems to discuss some possibly useful subparts but unless I am missing it I do not see the solution to what I really need and I that I am sure many others need as well. It is very important to me that it be a cli solution. Is this possible and if so how?

bitifet commented Dec 3, 2014

I had the same problem and zonaj's branch was really useful.
Also I made a few improvements (maybe they could be useful for anyone) in my own github repo. I just sent a pull request:

NOTE for Ubuntu/Debian users: I also had a small headache because official (and thereby zonaj's) versions doesn't work "out of the box" in Debian/Ubuntu. It throws a confusing error message saying that couldn't find libre/openoffice (while I have working ubuntu's unoconv version installed). ...This is not real. It is caused because Ubuntu/Debian's default python interpreter is 2.x instead of 3.x. Ubuntu's unoconv changes the script shebang from 'python' to 'python3' to address this., if you use Debian/Ubuntu, you would need to also change it or invoke the interpreter explicitly by typing 'python3 unoconv ...'.

EDIT: In Debian works fine with Python 2.x. The actual problem in ubuntu was the lack of python-uno package. Debian has both: python-uno and python3-uno, but Ubuntu comes only python3-uno. This is why they changes shebang of its unoconv package.

lagah commented Apr 22, 2015

I make zonaj's changes, result:

# unoconv3 -d spreadsheet -f html --sheet='Físico' 2.xlsx
  File "/usr/bin/unoconv3", line 856
    sheets.moveByName (op.sheetname, 0)
IndentationError: unindent does not match any outer indentation level

@dagwieers dagwieers modified the milestone: Release 0.8, Release 0.9 Jul 8, 2015

emoreth commented Nov 22, 2015

+1 for choosing sheets to export

Is this intended to be merged/re-implemented anytime ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment