Edit existing excel file (Python 3)

154 views
Skip to first unread message

Danthine Alexandre

unread,
May 30, 2016, 6:41:04 PM5/30/16
to python-excel
Hi, 

I read a lot about this subject but I can not find a clear answer to my problem.

I use Python 3 and I want to edit a existing excel file.

As I use Python 3, I can not use the package xlutils. 

I want to write in this file with index. For example : Sheet[0][1] = 7

In fact in openpyxl I can only use a string which target the right cell. I want to target a cell to write in by with two index as we can do with an array. Thank you for your advice ! Alexandre

Adrian Klaver

unread,
May 30, 2016, 8:23:48 PM5/30/16
to python...@googlegroups.com
On 05/30/2016 01:24 PM, Danthine Alexandre wrote:
> Hi,
>
> I read a lot about this subject but I can not find a clear answer to my
> problem.
>
> I use Python 3 and I want to edit a existing excel file.
>
> As I use Python 3, I can not use the package xlutils.
>
> I want to write in this file with index. For example : Sheet[0][1] = 7

The above is unclear to me. Do mean Sheet[0] and then cell[1] or
column[0], row[1] of some previously defined sheet or something else
entirely?

Or to put it another way how did you do this with xlutils?

>
> In fact in *openpyxl *I can only use a string which target the right
> cell. I want to target a cell to write in by with two index as we can do
> with an array. Thank you for your advice ! Alexandre
>
> --
> You received this message because you are subscribed to the Google
> Groups "python-excel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to python-excel...@googlegroups.com
> <mailto:python-excel...@googlegroups.com>.
> To post to this group, send email to python...@googlegroups.com
> <mailto:python...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/python-excel.
> For more options, visit https://groups.google.com/d/optout.


--
Adrian Klaver
adrian...@aklaver.com

Charlie Clark

unread,
May 31, 2016, 3:09:12 AM5/31/16
to python...@googlegroups.com
Am .05.2016, 22:24 Uhr, schrieb Danthine Alexandre
<alexandre...@gmail.com>:

> In fact in *openpyxl *I can only use a string which target the right
> cell.

ws.cell(row=x, colum=y) allows you to use numeric (1-based) indices in
openpyxl.
You can also do ws.rows[0][0]

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
Reply all
Reply to author
Forward
0 new messages