On Mon, 23 Mar 2015 19:09:53 +0100
"Charlie Clark" <
charli...@clark-consulting.eu> wrote:
> Am .03.2015, 18:06 Uhr, schrieb John Bovey <
J.D....@kent.ac.uk>:
>
>
> > What kind of comments do you mean, so I can generate an example and
> > make sure it is ok.
>
> Just add a comment to a cell. But I still don't know what you're working
> on with regard to the controls. An additional check that keep_vba==True ?
At present, if keep_vba is false then no vml files are preserved from
the loaded workbook and so there cannot be any legacyDrawing references
to them in the output worksheet. The easiest way I can see to do that is
to pass the keep_vba parameter through to the worksheet parser and make
the initialisation of vba_controls dependent on whether it is true.
Another solution would be to preserve vml files regardless of
the value of keep_vba. That would would also mean preserving the
entries in the sheet.xml.rels file. At present, I think those files are
preserved intact if keep_vba is true, which would probably break if
openpyxl tried to add any other drawings to the sheet. Another solution
would be to generate an exception if someone tries to load a
spreadsheet containing VBA but don't set keep_vba=True.
I have to take your lead on what is important. When I added the VBA
support I had a particular use-case in which I wanted to create
spreadsheets full of data (exam marks) but needed to have some VBA
functions there too so that people could manipulate the tables of
numbers in different ways. A convenient way to do that is to have a
template with the VBA and then use openpyxl to add the numeric data.
My feeling is, that is probably what most of the (very few?) people who
use openpyxl with VBA would want to do, but I am willing to be
corrected. Is it important to take care of far-fetched scenarios in
which people want to load spreadsheets containing macros, but
discard the macros or add drawings to the worksheets?
>
> What we really need is a proper modelling of the relationships so that the
> drawing will be preserved as a relationship even if the macro is dropped.
> But that's going to be a while coming I fear. With drawings the problem is
> exacerbated by the fact that VML isn't part of the specification. It's
> supposed to have been replaced by DrawingML but I suspect the support for
> this is poor for charts. Excel 2013 can apparently generate files based on
> the strict version of the spec but I can't find a similar switch in Excel
> 2015 for Mac preview. In the meantime we'll have to continue treating the
> drawings as blobs.
I agree entirely.
John