From: News123 on
Hi,

I'm making first attempts to modify a few cells of an openoffice
spreadsheet.

I thought I'll start with ooolib as it seems rather simple.

( linux / open office 3.1 / ooolib-python-0.0.16 )

My first test was just to open a spread sheet


import ooolib
doc = ooolib.Calc()
doc.load("doc1.ods") # load calc file
doc.set_sheet_index(0) # select first sheet
doc_dims = doc.get_sheet_dimensions() # get sheet dimensions
print "dims",doc_dims # and print them out
doc.save("doc2.ods") # save 'unmodfified' file


Extracting data works perfectly.

However the saved file lost all its formating and keeps only the data.

What am I doing wrong?

My goal is to just change one cell value, but to keep all the formatting
(at least of the other cells)


thanks for any hints


N
From: Kushal Kumaran on
On Thu, Apr 29, 2010 at 5:46 AM, News123 <news1234(a)free.fr> wrote:
> Hi,
>
> I'm making first attempts to modify a few cells of an openoffice
> spreadsheet.
>

Try the xlrd and xlwt modules, and the documentation at
http://www.python-excel.org/

> <snip>

--
regards,
kushal
From: News123 on


Kushal Kumaran wrote:
> On Thu, Apr 29, 2010 at 5:46 AM, News123 <news1234(a)free.fr> wrote:
>> Hi,
>>
>> I'm making first attempts to modify a few cells of an openoffice
>> spreadsheet.
>>
>
> Try the xlrd and xlwt modules, and the documentation at
> http://www.python-excel.org/

Thanks Kumar,

I installed xlrd, xlwt and xlsutils

Now I'm stuck with exactly the same probem, that I had with ooolib.
The newly written file lost all formating and replaced formulas with the
calculated values.


Does anyone have a simple example, which reads a file, modifies one cell
and writes out WITHOUT oss of formatting / formulas?


from xlrd import open_workbook
from xlutils.copy import copy

rb = open_workbook('doc1.xls')
print "WB with %d sheets" % rb.nsheets
wb = copy(rb)
wb.save("doc2.xls") # file is created, but ALL formattng is lost and
formulas are now diplayed as text




>
>> <snip>
>
From: News123 on
News123 wrote:
>
> Kushal Kumaran wrote:
>> On Thu, Apr 29, 2010 at 5:46 AM, News123 <news1234(a)free.fr> wrote:
>>> Hi,
>>>
>>> I'm making first attempts to modify a few cells of an openoffice
>>> spreadsheet.
>>>
>> Try the xlrd and xlwt modules, and the documentation at
>> http://www.python-excel.org/

> I installed xlrd, xlwt and xlsutils
>
> Now I'm stuck with exactly the same probem, that I had with ooolib.
> The newly written file lost all formating and replaced formulas with the
> calculated values.
>

Well the xlsutils documentation states clearly:
> It is important to note that some things won't be copied:
> Formulae
> •
> Names
> •
> anything ignored by xlrd
> •


So probably I can't use xlrd / xlwt to perform my desired task. :-(
(Or it least I don't know how)

For extracting data or creating xls from scratch t seems rather nice though


bye


N
From: cjw on
On 28-Apr-10 23:18 PM, Kushal Kumaran wrote:
> On Thu, Apr 29, 2010 at 5:46 AM, News123<news1234(a)free.fr> wrote:
>> Hi,
>>
>> I'm making first attempts to modify a few cells of an openoffice
>> spreadsheet.
>>
>
> Try the xlrd and xlwt modules, and the documentation at
> http://www.python-excel.org/
The tutorial here is beautifully done:

http://python-excel.googlegroups.com/web/python-excel.pdf?gda=68Un3kIAAABrjVmXvI2FnKbK79o6Y1oCuHLcf1VKsaM-EVGjvOiGtNXEtWX7y7b6ByPnawQ3OxpV4u3aa4iAIyYQIqbG9naPgh6o8ccLBvP6Chud5KMzIQ

Does it fly with .ods files?

Colin W.

>
>> <snip>
>