problem opening .xlsm

7,021 views
Skip to first unread message

abi navigator

unread,
Feb 7, 2012, 4:01:11 AM2/7/12
to openpyxl-users
Hello,
I'm generating an empty .xlsm file using following code:

###
from openpyxl import Workbook

wb = Workbook()
fileName = r'myEmptyFile.xlsm'
ws = wb.create_sheet()
ws.title = 'empty worksheet'

wb.save(filename = fileName)
###

Excel2007 is not able to open myEmptyFile.xlsm file and reports
following:
"Excel cannot open the file 'myEmptyFile.xlsm' because the file format
or file extension is not valid. Verify ..."

If I change the file extension from .xlsm to .xlsx, excel2007 opens it
without any problem.

Other specification:
- openpyxl = 1.5.7
- python = 2.7
- win XP SP3

Does anybody have any idea where is the problem?

Thanks for response,
Abi

Eric Gazoni

unread,
Feb 7, 2012, 4:09:44 AM2/7/12
to openpyx...@googlegroups.com
Hi,
I think you should not give the xlsM extension, because the file will
contain no VBA code.
openpyxl is used to build xlsX files only ;-)

However, LibreOffice does not complain about the file, so it's probably
MS Excel specific.

Try renaming the file and let us know !

Cheers,
Eric

Le 7/02/12 10:01, abi navigator a �crit :

Aron Kisdi

unread,
Mar 5, 2012, 7:02:21 AM3/5/12
to openpyx...@googlegroups.com
Hi,
 
Excel will search for VBA which will not be there if you create the file with openpyxl.
 
However you can edit and save .xlsm files with openpyxl provided you created them (even if it is just an empty file) with Excel. Tested with Office 2010 and openpyxl 1.5.5
 
I hope this helps,
 
Aron

On 7 February 2012 09:09, Eric Gazoni <eric....@gmail.com> wrote:
Hi,
I think you should not give the xlsM extension, because the file will
contain no VBA code.
openpyxl is used to build xlsX files only ;-)

However, LibreOffice does not complain about the file, so it's probably
MS Excel specific.

Try renaming the file and let us know !

Cheers,
Eric

Le 7/02/12 10:01, abi navigator a écrit :

Christoph M.

unread,
Apr 19, 2012, 6:57:20 PM4/19/12
to openpyxl-users
Hi!
I have a similar problem.

openpyxl works fine with .xlsx files. Loading and saving methods both
work and produce perfect results.
But when I try to edit an .xlsm file containing VBA code, I can load
it just like an .xlsx file and manipulate the values of cell values.
The file produced by the save-method however is corrupt. It occupies a
lot less disk memory than the original file, so probably the VBA code
is not transmitted.
I use Office 2007 as well. But I cannot imagine, that is really the
problem here.

I need a possibility to edit .xlsm files online. I first tried
PHPExcel, but then found out, it cannot handle makro containing files.
So I searched for alternatives and stumbles over python openpyxl. It
is said in every description that you can work with .xlsx/.xlsm files
and I almost got it to work now, but again I strand at the .xlsm
files? :(

I would really appreciate if someone has a solution here...

Cheers,
Chris


On 5 Mrz., 07:02, Aron Kisdi <kis...@gmail.com> wrote:
> Hi,
>
> Excel will search for VBA which will not be there if you create the file
> with openpyxl.
>
> However you can edit and save .xlsm files with openpyxl provided you
> created them (even if it is just an empty file) with Excel. Tested with
> Office 2010 and openpyxl 1.5.5
>
> I hope this helps,
>
> Aron
>

jlgut...@gmail.com

unread,
Jun 27, 2013, 12:07:30 PM6/27/13
to openpyx...@googlegroups.com
Aron,

How do you go about performing this?  I have a very similar situation running Windows-7, Python 2.6, and openpyxl 1.6.2.  In this scenario, I am trying to update an Excel-created .xlsm, specifically a cell value.  The code I have running is as follows:

dcm_wb= load_workbook("filepath.xlsm")
dcm_ws = dcm_wb.get_sheet_by_name("ws")
duration_cell = dcm_ws.cell("E14")
duration_cell.value = 4
dcm_wb.save("filepath.xlsm")

where I am trying to load a value of 4 into cell E14 and save the edits.  However, overriding the original "filepath.xlsm" seems to remove the macros in the original.  I have not altered any of the macros themselves.

Any help would be appreciated,
Joseph

John Bovey

unread,
Jun 27, 2013, 12:29:05 PM6/27/13
to openpyx...@googlegroups.com
The amorris fork does support the retention of vba but it has not been
merged into the root yet. If you want to give it a try you will need to
call load_workbook() with the additional parameter keep_vba=true.

John Bovey
Message has been deleted

jlgut...@gmail.com

unread,
Jun 27, 2013, 2:28:27 PM6/27/13
to openpyx...@googlegroups.com, j.d....@kent.ac.uk
John,

Is this included in the 1.6.2 install?  I have tried the following:

dcm_wb= load_workbook("filepath.xlsm", keep_vba=True)

dcm_ws = dcm_wb.get_sheet_by_name("ws")
duration_cell = dcm_ws.cell("E14")
duration_cell.value = 4
dcm_wb.save("filepath.xlsm")

and it returned:

"TypeError: load_workbook() got an unexpected keyword argument 'keep_vba'"

I'll apologize upfront, I am green when it comes to coding.

Thanks again,
Joseph

------------------------------------------------------------------------------------------------------------

Charlie Clark

unread,
Jun 27, 2013, 2:37:38 PM6/27/13
to openpyx...@googlegroups.com
Am 27.06.2013, 20:21 Uhr, schrieb <jlgut...@gmail.com>:

> John,
> Is this included in the 1.6.2 install?

No, it's waiting to be integrated into the next release.

https://bitbucket.org/amorris/openpyxl/commits/branch/default

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

Adam Morris

unread,
Jun 27, 2013, 3:25:42 PM6/27/13
to openpyx...@googlegroups.com
If you have a chance to test, I'm sure both John and myself would appreciate any feedback.


--Adam

John Bovey

unread,
Jun 28, 2013, 3:42:22 AM6/28/13
to openpyx...@googlegroups.com
On Thu, 27 Jun 2013 12:25:42 -0700 (PDT)
Adam Morris <w...@myemptybucket.com> wrote:

> If you have a chance to test, I'm sure both John and myself would
> appreciate any feedback.
>
> You can download the branch
> here: https://bitbucket.org/amorris/openpyxl/get/default.zip
>
> --Adam

I have just had a thought on this. My code to preserve included VBA
makes use of the xml.etree.ElementTree.register_namespace()
function which was only introduced in python 2.7. If this is a problem
then let me know and I will try to find a way to manage without that
function.

John

jlgut...@gmail.com

unread,
Jun 28, 2013, 1:12:18 PM6/28/13
to openpyx...@googlegroups.com, j.d....@kent.ac.uk
John & Adam,

My apologies I was using 2.6 because of an ArcGIS 10 install on my cpu.  After installing Python 2.7.5 and running the new version of openpyxl, I ran the following code:

I ran the following code:
wb= load_workbook("filepath.xlsm", keep_vba=True)
ws = wb.get_sheet_by_name("ws")
ws.cell("E14").value = 4
wb.save("filepath.xlsm")

which generated in the following error

Traceback (most recent call last):
  File "C:\Users\user\My Documents\Aptana Studio 3 Workspace\PyECAT27\userinput.py", line 441, in <module>
    dcm_wb.save("c:\ECAT\DCM\DCM.xlsm")
  File "build\bdist.win-amd64\egg\openpyxl\workbook.py", line 215, in save
  File "build\bdist.win-amd64\egg\openpyxl\writer\excel.py", line 163, in save_workbook
  File "build\bdist.win-amd64\egg\openpyxl\writer\excel.py", line 146, in save
  File "build\bdist.win-amd64\egg\openpyxl\writer\excel.py", line 66, in write_data
  File "build\bdist.win-amd64\egg\openpyxl\writer\workbook.py", line 64, in write_content_types
  File "C:\Python27\lib\zipfile.py", line 931, in read
    return self.open(name, "r", pwd).read()
  File "C:\Python27\lib\zipfile.py", line 976, in open
    zinfo.orig_filename, fname)
zipfile.BadZipfile: File name in directory "[Content_Types].xml" and header "xl/sharedStrings.xml" differ.

I was able to successfully convert most of the vba when I gave the output .xlsm a different name but there were still some macros that were erroneous.

-Joseph

destr...@gmail.com

unread,
Dec 10, 2013, 12:09:43 AM12/10/13
to openpyx...@googlegroups.com, j.d....@kent.ac.uk
Hi all,

I am facing a similar issue when trying to save an xlsm file.
I am able to open it, edit it and save it without any issue if the file is in xlsx format. However, if the file is in xlsm format, even though I can open and edit it (loading with the keep_vba=True option), I get the error when I try to save it.

This is the code I am using:
from openpyxl import load_workbook
import csv
def update_xlsx(src, dest):
    #Open an xlsx for reading
    wb = load_workbook(filename = dest, keep_vba=True)
    #Get the current Active Sheet
    # ws = wb.get_active_sheet()
    # print ws.title
    #You can also select a particular sheet
    #based on sheet name
    ws = wb.get_sheet_by_name("OnPeak")
    #Open the csv file
    with open(src,'rU') as fin:
        #read the csv
        reader = csv.reader(fin)
        #enumerate the rows, so that you can
        #get the row index for the xlsx
        for index,row in enumerate(reader):
            # if index < 6: continue
            #Asssuming space sepeated,
            #Access the particular cell and assign
            #the value from the csv row
            ws.cell(row=index,column=3).value = row[3]
            ws.cell(row=index,column=4).value = row[4]
    #save the csb file
    wb.save(dest)


and this is the error I get:


---------------------------------------------------------------------------
BadZipfile                                Traceback (most recent call last)
<ipython-input-132-8142f5d8ab79> in <module>()
----> 1 update_xlsx("Jul_2013_Q2.csv", "Jul_2013_Q2.xlsm")

<ipython-input-131-311af13ce2a6> in update_xlsx(src, dest)
     30             ws.cell(row=index,column=4).value = row[4]
     31     #save the csb file
---> 32     wb.save(dest)

/Library/Python/2.7/site-packages/openpyxl/workbook.pyc in save(self, filename)
    230             save_dump(self, filename)
    231         else:
--> 232             save_workbook(self, filename)

/Library/Python/2.7/site-packages/openpyxl/writer/excel.pyc in save_workbook(workbook, filename)
    157     """
    158     writer = ExcelWriter(workbook)
--> 159     writer.save(filename)
    160     return True
    161 

/Library/Python/2.7/site-packages/openpyxl/writer/excel.pyc in save(self, filename)
    140         """Write data into the archive."""
    141         archive = ZipFile(filename, 'w', ZIP_DEFLATED)
--> 142         self.write_data(archive)
    143         archive.close()
    144 

/Library/Python/2.7/site-packages/openpyxl/writer/excel.pyc in write_data(self, archive)
     60         shared_string_table = self._write_string_table(archive)
     61 
---> 62         archive.writestr(ARC_CONTENT_TYPES, write_content_types(self.workbook))
     63         if not self.workbook.vba_archive:
     64             archive.writestr(ARC_ROOT_RELS, write_root_rels(self.workbook))

/Library/Python/2.7/site-packages/openpyxl/writer/workbook.pyc in write_content_types(workbook)
     62     seen = set()
     63     if workbook.vba_archive:
---> 64         root = fromstring(workbook.vba_archive.read(ARC_CONTENT_TYPES))
     65         register_namespace('', 'http://schemas.openxmlformats.org/package/2006/content-types')
     66         for elem in root.findall('{http://schemas.openxmlformats.org/package/2006/content-types}Override'):

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.pyc in read(self, name, pwd)
    929     def read(self, name, pwd=None):
    930         """Return file bytes (as a string) for name."""
--> 931         return self.open(name, "r", pwd).read()
    932 
    933     def open(self, name, mode="r", pwd=None):

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.pyc in open(self, name, mode, pwd)
    974                 raise BadZipfile, \
    975                         'File name in directory "%s" and header "%s" differ.' % (
--> 976                             zinfo.orig_filename, fname)
    977 
    978             # check for encrypted flag & handle password


BadZipfile: File name in directory "[Content_Types].xml" and header "xl/sharedStrings.xml" differ.

John Bovey

unread,
Dec 10, 2013, 2:27:43 AM12/10/13
to openpyx...@googlegroups.com
On Mon, 9 Dec 2013 21:09:43 -0800 (PST)
destr...@gmail.com wrote:

> Hi all,
>
> I am facing a similar issue when trying to save an xlsm file.
> I am able to open it, edit it and save it without any issue if the file is
> in xlsx format. However, if the file is in xlsm format, even though I can
> open and edit it (loading with the keep_vba=True option), I get the error
> when I try to save it.

Hi,

I'll have a look into this but it will not be for a few days. I've not
been anywhere near openpyxl for a few months and it will take me a
while to catch up with all the changes that have been made.

John

Nick

unread,
Dec 10, 2013, 10:12:33 AM12/10/13
to openpyx...@googlegroups.com
I'm having a similar problem when using the keep_vba=True option, however I am receiving an error when saving the workbook, specifically when the worksheets are being written:

  File "C:\Python27\lib\site-packages\openpyxl\workbook.py", line 232, in save
    save_workbook(self, filename)
  File "C:\Python27\lib\site-packages\openpyxl\writer\excel.py", line 159, in save_workbook
    writer.save(filename)
  File "C:\Python27\lib\site-packages\openpyxl\writer\excel.py", line 142, in save
    self.write_data(archive)
  File "C:\Python27\lib\site-packages\openpyxl\writer\excel.py", line 83, in write_data
    self._write_worksheets(archive, shared_string_table, self.style_writer)
  File "C:\Python27\lib\site-packages\openpyxl\writer\excel.py", line 104, in _write_worksheets
    style_writer.get_style_by_hash()))
  File "C:\Python27\lib\site-packages\openpyxl\writer\worksheet.py", line 74, in write_worksheet
heet.title)
AttributeError: 'NoneType' object has no attribute 'get'

The workbook was written and some of the contents can be recovered, but only the worksheet with the macro on it was actually saved. The rest of the worksheets are blank.
using: python 2.7
openpyxl: 1.7
Any help would be appreciated,
Nick

Charlie Clark

unread,
Dec 10, 2013, 10:19:43 AM12/10/13
to openpyx...@googlegroups.com
Am .12.2013, 16:12 Uhr, schrieb Nick <presco...@gmail.com>:

> The workbook was written and some of the contents can be recovered, but
> only the worksheet with the macro on it was actually saved. The rest of
> the
> worksheets are blank.
> using: python 2.7
> openpyxl: 1.7
> Any help would be appreciated,

Is it going to be possible to supply a sample file for this?

Otherwise you may have to do some digging and debugging yourself. openpyxl
didn't support preserving macros before 1.7 so John's work hasn't had a
heap of testing.

Nick

unread,
Dec 10, 2013, 10:31:30 AM12/10/13
to openpyx...@googlegroups.com
The included file has a macro on the first worksheet that counts the different 'status' cells on the other worksheets.
I can reproduce the issue with these steps:
wb = load_workbook(file_path, keep_vba=True)
wb.save("new" +file_path)

-Nick
testwb.xlsm

John Bovey

unread,
Dec 10, 2013, 5:03:27 PM12/10/13
to openpyx...@googlegroups.com
On Tue, 10 Dec 2013 07:31:30 -0800 (PST)
Nick <presco...@gmail.com> wrote:

> The included file has a macro on the first worksheet that counts the
> different 'status' cells on the other worksheets.
> I can reproduce the issue with these steps:
> wb = load_workbook(file_path, keep_vba=True)
> wb.save("new" +file_path)

That is useful, thanks. I should be able to look at it next week.

John

John Bovey

unread,
Dec 18, 2013, 9:22:33 AM12/18/13
to openpyx...@googlegroups.com
I have fixed the bug that was causing this crash, the fixed version is
in https://jbo...@bitbucket.org/jbovey/openpyxl for now.

The saved spreadsheet seems to have working macros but xml complains
that it needs to repair it when it first loads it. Is this a known
problem? The saved workbook zip archive seems to be missing some xml
files that are in the original spreadsheet zip archive, for example the
directory customXml. As far as I know, these are not related to vba but
if that is not correct I can arrange for them to be copied intact to
the saved archive.

John

On Tue, 10 Dec 2013 07:31:30 -0800 (PST)
Nick <presco...@gmail.com> wrote:

Charlie Clark

unread,
Dec 18, 2013, 10:06:23 AM12/18/13
to openpyx...@googlegroups.com
Am .12.2013, 15:22 Uhr, schrieb John Bovey <J.D....@kent.ac.uk>:

> I have fixed the bug that was causing this crash, the fixed version is
> in https://jbo...@bitbucket.org/jbovey/openpyxl for now.

> The saved spreadsheet seems to have working macros but xml complains
> that it needs to repair it when it first loads it. Is this a known
> problem? The saved workbook zip archive seems to be missing some xml
> files that are in the original spreadsheet zip archive, for example the
> directory customXml. As far as I know, these are not related to vba but
> if that is not correct I can arrange for them to be copied intact to
> the saved archive.

As I found out when working on charts, Excel's error messages are worse
than useless. The "Productivity Tool" which John McNamara pointed me to is
really helpful in finding out what Excel doesn't actually like - you can
compare two files with each other and use the validator to find out if
you've generated rubbish.

When using it with openpyxl you need to hack writer/workbook.py so that
the root element has no namespace

This is

NSMAP = {None :
"http://schemas.openxmlformats.org/package/2006/content-types"}
root = Element('{%s}Types' % CONTYPES_NS, nsmap=NSMAP)

In write_content_types() with lxml installed which I recommend for
development, well it's a prerequisite for running the tests.
Unfortunately, I haven't come across the equivalent when using the
standard library's ElementTree but it's on the list.

John Bovey

unread,
Dec 20, 2013, 3:57:06 AM12/20/13
to openpyx...@googlegroups.com
On Wed, 18 Dec 2013 16:06:23 +0100
"Charlie Clark" <charli...@clark-consulting.eu> wrote:

> As I found out when working on charts, Excel's error messages are worse
> than useless. The "Productivity Tool" which John McNamara pointed me to is
> really helpful in finding out what Excel doesn't actually like - you can
> compare two files with each other and use the validator to find out if
> you've generated rubbish.
>
> When using it with openpyxl you need to hack writer/workbook.py so that
> the root element has no namespace
>
> This is
>
> NSMAP = {None :
> "http://schemas.openxmlformats.org/package/2006/content-types"}
> root = Element('{%s}Types' % CONTYPES_NS, nsmap=NSMAP)
>
> In write_content_types() with lxml installed which I recommend for
> development, well it's a prerequisite for running the tests.
> Unfortunately, I haven't come across the equivalent when using the
> standard library's ElementTree but it's on the list.

I have installed the productivity tool. Do I need to use a different
fork of openpyxl from the 1.8 one I am working with at the moment.
Sorry, I have been away from openpyxl for a few months and I'm a bit
out of touch.

John

Charlie Clark

unread,
Dec 20, 2013, 5:31:02 AM12/20/13
to openpyx...@googlegroups.com
Am .12.2013, 09:57 Uhr, schrieb John Bovey <J.D....@kent.ac.uk>:

> I have installed the productivity tool. Do I need to use a different
> fork of openpyxl from the 1.8 one I am working with at the moment.
> Sorry, I have been away from openpyxl for a few months and I'm a bit
> out of touch.

No, 1.8 is the one to use but you'll the need the hack.

John Bovey

unread,
Dec 20, 2013, 6:05:46 AM12/20/13
to openpyx...@googlegroups.com
On Fri, 20 Dec 2013 11:31:02 +0100
"Charlie Clark" <charli...@clark-consulting.eu> wrote:

> > I have installed the productivity tool. Do I need to use a different
> > fork of openpyxl from the 1.8 one I am working with at the moment.
> > Sorry, I have been away from openpyxl for a few months and I'm a bit
> > out of touch.
>
> No, 1.8 is the one to use but you'll the need the hack.

Thanks. The code has changed quite a lot since I worked on it 18 months
ago.

John

Charlie Clark

unread,
Dec 20, 2013, 6:17:38 AM12/20/13
to openpyx...@googlegroups.com
Am .12.2013, 12:05 Uhr, schrieb John Bovey <J.D....@kent.ac.uk>:

> Thanks. The code has changed quite a lot since I worked on it 18 months
> ago.

Hopefully for the better…

John Bovey

unread,
Dec 20, 2013, 6:35:05 AM12/20/13
to openpyx...@googlegroups.com
On Fri, 20 Dec 2013 12:17:38 +0100
"Charlie Clark" <charli...@clark-consulting.eu> wrote:

> > Thanks. The code has changed quite a lot since I worked on it 18 months
> > ago.
>
> Hopefully for the better…

Undoubtably.

The productivity tool is displaying the error message:

"Cannot open the file: An item with the same key has already been
added."

Does every root element need to have no namespace?

John

Charlie Clark

unread,
Dec 20, 2013, 6:52:47 AM12/20/13
to openpyx...@googlegroups.com
Am .12.2013, 12:35 Uhr, schrieb John Bovey <J.D....@kent.ac.uk>:

> Undoubtably.

> The productivity tool is displaying the error message:
> "Cannot open the file: An item with the same key has already been
> added."

Not had that one. You might want to make the file available for
inspection. Double check the archive.

> Does every root element need to have no namespace?

No. The XML we generate is perfectly valid, it's just that the Excel
validator chokes on this particular file if there is a default such as ns0
- the standard for undefined namespaces.

John Bovey

unread,
Dec 20, 2013, 7:02:43 AM12/20/13
to openpyx...@googlegroups.com
On Fri, 20 Dec 2013 12:52:47 +0100
"Charlie Clark" <charli...@clark-consulting.eu> wrote:

> > The productivity tool is displaying the error message:
> > "Cannot open the file: An item with the same key has already been
> > added."
>
> Not had that one. You might want to make the file available for
> inspection. Double check the archive.

I am checking the archive and I have fixed that one, I had duplicate
entries in Content_Types. Now I am getting: "Specified part does not
exist in the package."

Progress of a kind.

John

John Bovey

unread,
Dec 20, 2013, 10:17:10 AM12/20/13
to openpyx...@googlegroups.com
On Tue, 10 Dec 2013 07:31:30 -0800 (PST)
Nick <presco...@gmail.com> wrote:

> The included file has a macro on the first worksheet that counts the
> different 'status' cells on the other worksheets.
> I can reproduce the issue with these steps:
> wb = load_workbook(file_path, keep_vba=True)
> wb.save("new" +file_path)

I think that this problem is now fixed in the branch at:

https://jbo...@bitbucket.org/jbovey/openpyxl

Is anybody able to test it before I get the changes merged into the
main branch?

John

Charlie Clark

unread,
Dec 20, 2013, 1:30:07 PM12/20/13
to openpyx...@googlegroups.com
Am .12.2013, 16:17 Uhr, schrieb John Bovey <J.D....@kent.ac.uk>:

>
> Is anybody able to test it before I get the changes merged into the
> main branch?

Feel free to submit a pull request any time. It makes code review easier
and won't stop you working on code.

Nick

unread,
Dec 20, 2013, 2:46:55 PM12/20/13
to openpyx...@googlegroups.com, j.d....@kent.ac.uk
Tested your changes, and while I no longer get an error when writing the new file, I do get an error when opening the workbook : "Excel found unreadable content...do you want to recover the contents..."
Excel is unable to recover/repair the content and gives me this error:
Replaced Part: /xl/worksheets/sheet1.xml part with XML error.  Undeclared prefix. Line 1, column 29100.

This is using the test workbook that I provided and just loading and saving it. Are you seeing the same behavior?

Nick

John Bovey

unread,
Dec 20, 2013, 3:08:04 PM12/20/13
to openpyx...@googlegroups.com
I thought that I had fixed that. When did you take your copy of the repository?
--
Sent from my Android phone.

John Bovey

unread,
Dec 20, 2013, 4:40:44 PM12/20/13
to openpyx...@googlegroups.com
On Fri, 20 Dec 2013 11:46:55 -0800 (PST)
Nick <presco...@gmail.com> wrote:

> Tested your changes, and while I no longer get an error when writing the
> new file, I do get an error when opening the workbook : "Excel found
> unreadable content...do you want to recover the contents..."
> Excel is unable to recover/repair the content and gives me this error:
> Replaced Part: /xl/worksheets/sheet1.xml part with XML error. Undeclared
> prefix. Line 1, column 29100.
>
> This is using the test workbook that I provided and just loading and saving
> it. Are you seeing the same behavior?

I hope that I have fixed it now. Let me know if anything else is broken.

John

Charlie Clark

unread,
Dec 20, 2013, 4:47:26 PM12/20/13
to openpyx...@googlegroups.com
Am .12.2013, 22:40 Uhr, schrieb John Bovey <J.D....@kent.ac.uk>:

>
> I hope that I have fixed it now. Let me know if anything else is broken.

Have you run the tests under Python 3 for that?

Install tox and bin/tox

I've only had a look at that commit but I'm not convinced that that code
is the solution.

Could you possibly write a test for it? You can add it to the tox nolxml
configuration to be able to run it easily.

John Bovey

unread,
Dec 20, 2013, 5:08:21 PM12/20/13
to openpyx...@googlegroups.com
On Fri, 20 Dec 2013 22:47:26 +0100
"Charlie Clark" <charli...@clark-consulting.eu> wrote:

> Am .12.2013, 22:40 Uhr, schrieb John Bovey <J.D....@kent.ac.uk>:
>
> >
> > I hope that I have fixed it now. Let me know if anything else is broken.
>
> Have you run the tests under Python 3 for that?
No, I'll try and do it over the Christmas break.
>
> Install tox and bin/tox
>
> I've only had a look at that commit but I'm not convinced that that code
> is the solution.
I agree that it is not very pretty. It might be better to drop trying
to support legacy controls. The hack stops it breaking when there aren't
any. I still need to check that it works when there are
some.
>
> Could you possibly write a test for it? You can add it to the tox nolxml
> configuration to be able to run it easily.

Yes, I will. I'll need to set up a sheet with controls and test that
they survive.

Incidentally, would it be better to have a developer mailing list
rather than inflict all this detail on users?

John

Charlie Clark

unread,
Dec 20, 2013, 5:20:53 PM12/20/13
to openpyx...@googlegroups.com
Am .12.2013, 23:08 Uhr, schrieb John Bovey <J.D....@kent.ac.uk>:

> No, I'll try and do it over the Christmas break.

Any checkout will already contain the right configuration. Just pip
install tox and bin/tox -e py33
Takes the hassle out of setting any additional virtualenv's up.

>> Install tox and bin/tox
>>
>> I've only had a look at that commit but I'm not convinced that that code
>> is the solution.

> I agree that it is not very pretty. It might be better to drop trying
> to support legacy controls. The hack stops it breaking when there aren't
> any. I still need to check that it works when there are
> some.

I'd really need to see what you're doing in greater detail. Serialising
via tostring in anything but test code looks very fishy.

>> Could you possibly write a test for it? You can add it to the tox nolxml
>> configuration to be able to run it easily.

> Yes, I will. I'll need to set up a sheet with controls and test that
> they survive.

We should try and preserve any objects that we can read but I wouldn't
support it otherwise.

> Incidentally, would it be better to have a developer mailing list
> rather than inflict all this detail on users?

I doubt it: the list is low traffic and I think most of the regular
readers are devs. I suspect a lot of users post via the web and only ever
see responses to their question. We have been given an open source account
(Jira, etc.) by Atlassian but neither Eric nor myself have really had time
to look at this in detail.

John Bovey

unread,
Dec 20, 2013, 6:04:47 PM12/20/13
to openpyx...@googlegroups.com
On Fri, 20 Dec 2013 23:20:53 +0100
"Charlie Clark" <charli...@clark-consulting.eu> wrote:

> I'd really need to see what you're doing in greater detail. Serialising
> via tostring in anything but test code looks very fishy.
>
> >> Could you possibly write a test for it? You can add it to the tox nolxml
> >> configuration to be able to run it easily.
>
> > Yes, I will. I'll need to set up a sheet with controls and test that
> > they survive.
>
> We should try and preserve any objects that we can read but I wouldn't
> support it otherwise.

I agree that the vba / form-controls stuff needs to be better
integrated. Initially I added vba support because I needed
it myself and I wanted to be sure that nothing would break if keep_vba
was false.

John

Charlie Clark

unread,
Dec 21, 2013, 4:41:42 AM12/21/13