Well, even a 3K or 6K zip does not post, so here is the code block for your reference:
import xml.etree.ElementTree as ET
from pprint import pprint
### from 3.2.0 openpyxl/drawing/anchor.py
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.descriptors import (
Typed,
Bool,
NoneSet,
Alias,
)
from openpyxl.descriptors.nested import (
NestedText,
)
from openpyxl.descriptors.excel import Relation
###LFC: added openpyxl.drawing for the following imports, because the file was pulled in locally
from openpyxl.drawing.xdr import (
XDRPoint2D,
XDRPositiveSize2D,
)
from openpyxl.drawing.connector import Shape
from openpyxl.drawing.graphic import (
GroupShape,
GraphicFrame,
)
from openpyxl.drawing.picture import PictureFrame
###LFC: EOF added openpyxl.drawing for the following imports
class AnchorClientData(Serialisable):
fLocksWithSheet = Bool(allow_none=True)
fPrintsWithSheet = Bool(allow_none=True)
def __init__(self,
fLocksWithSheet=None,
fPrintsWithSheet=None,
):
self.fLocksWithSheet = fLocksWithSheet
self.fPrintsWithSheet = fPrintsWithSheet
class AnchorMarker(Serialisable):
tagname = "marker"
col = NestedText(expected_type=int)
colOff = NestedText(expected_type=int)
row = NestedText(expected_type=int)
rowOff = NestedText(expected_type=int)
def __init__(self,
col=0,
colOff=0,
row=0,
rowOff=0,
):
self.col = col
self.colOff = colOff
self.row = row
self.rowOff = rowOff
class _AnchorBase(Serialisable):
#one of
sp = Typed(expected_type=Shape, allow_none=True)
shape = Alias("sp")
grpSp = Typed(expected_type=GroupShape, allow_none=True)
groupShape = Alias("grpSp")
graphicFrame = Typed(expected_type=GraphicFrame, allow_none=True)
cxnSp = Typed(expected_type=Shape, allow_none=True)
connectionShape = Alias("cxnSp")
pic = Typed(expected_type=PictureFrame, allow_none=True)
contentPart = Relation()
clientData = Typed(expected_type=AnchorClientData)
__elements__ = ('sp', 'grpSp', 'graphicFrame',
'cxnSp', 'pic', 'contentPart', 'clientData')
def __init__(self,
clientData=None,
sp=None,
grpSp=None,
graphicFrame=None,
cxnSp=None,
pic=None,
contentPart=None
):
if clientData is None:
clientData = AnchorClientData()
self.clientData = clientData
self.sp = sp
self.grpSp = grpSp
self.graphicFrame = graphicFrame
self.cxnSp = cxnSp
self.pic = pic
self.contentPart = contentPart
@property
def _content(self):
"""
What kind of content does the anchor contain
"""
if self.pic is not None:
return self.pic
elif self.groupShape is not None:
return self.groupShape
elif self.connectionShape is None:
return self.connectionShape
elif self.shape is not None:
return self.shape
class AbsoluteAnchor(_AnchorBase):
tagname = "absoluteAnchor"
pos = Typed(expected_type=XDRPoint2D)
ext = Typed(expected_type=XDRPositiveSize2D)
sp = _AnchorBase.sp
grpSp = _AnchorBase.grpSp
graphicFrame = _AnchorBase.graphicFrame
cxnSp = _AnchorBase.cxnSp
pic = _AnchorBase.pic
contentPart = _AnchorBase.contentPart
clientData = _AnchorBase.clientData
__elements__ = ('pos', 'ext') + _AnchorBase.__elements__
def __init__(self,
pos=None,
ext=None,
**kw
):
if pos is None:
pos = XDRPoint2D(0, 0)
self.pos = pos
if ext is None:
ext = XDRPositiveSize2D(0, 0)
self.ext = ext
super().__init__(**kw)
class OneCellAnchor(_AnchorBase):
tagname = "oneCellAnchor"
_from = Typed(expected_type=AnchorMarker)
ext = Typed(expected_type=XDRPositiveSize2D)
sp = _AnchorBase.sp
grpSp = _AnchorBase.grpSp
graphicFrame = _AnchorBase.graphicFrame
cxnSp = _AnchorBase.cxnSp
pic = _AnchorBase.pic
contentPart = _AnchorBase.contentPart
clientData = _AnchorBase.clientData
__elements__ = ('_from', 'ext') + _AnchorBase.__elements__
def __init__(self,
_from=None,
ext=None,
**kw
):
if _from is None:
_from = AnchorMarker()
self._from = _from
if ext is None:
ext = XDRPositiveSize2D(0, 0)
self.ext = ext
super().__init__(**kw)
class TwoCellAnchor(_AnchorBase):
tagname = "twoCellAnchor"
editAs = NoneSet(values=(['twoCell', 'oneCell', 'absolute']))
_from = Typed(expected_type=AnchorMarker)
to = Typed(expected_type=AnchorMarker)
sp = _AnchorBase.sp
grpSp = _AnchorBase.grpSp
graphicFrame = _AnchorBase.graphicFrame
cxnSp = _AnchorBase.cxnSp
pic = _AnchorBase.pic
contentPart = _AnchorBase.contentPart
clientData = _AnchorBase.clientData
__elements__ = ('_from', 'to') + _AnchorBase.__elements__
def __init__(self,
editAs=None,
_from=None,
to=None,
**kw
):
self.editAs = editAs
if _from is None:
_from = AnchorMarker()
self._from = _from
if to is None:
to = AnchorMarker()
self.to = to
super().__init__(**kw)
### EOF from 3.2.0 openpyxl/drawing/anchor.py
### from 3.2.0 openpyxl/worksheet/ole.py
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.descriptors import (
Typed,
Integer,
String,
Set,
Bool,
Sequence,
)
from openpyxl.descriptors.nested import NestedText
### LFC: include above --- from openpyxl.drawing.anchor import AnchorMarker
from openpyxl.xml.constants import SHEET_DRAWING_NS
class AnchorMarker(AnchorMarker):
## XDR namespace for child elements only
col = NestedText(expected_type=int, namespace=SHEET_DRAWING_NS)
colOff = NestedText(expected_type=int, namespace=SHEET_DRAWING_NS)
row = NestedText(expected_type=int, namespace=SHEET_DRAWING_NS)
rowOff = NestedText(expected_type=int, namespace=SHEET_DRAWING_NS)
class ObjectAnchor(Serialisable):
tagname = "anchor"
_from = Typed(expected_type=AnchorMarker)
to = Typed(expected_type=AnchorMarker)
moveWithCells = Bool(allow_none=True)
sizeWithCells = Bool(allow_none=True)
z_order = Integer(allow_none=True, hyphenated=True)
def __init__(self,
_from=None,
to=None,
moveWithCells=False,
sizeWithCells=False,
z_order=None,
):
self._from = _from
self.to = to
self.moveWithCells = moveWithCells
self.sizeWithCells = sizeWithCells
self.z_order = z_order
class ObjectPr(Serialisable):
tagname = "objectPr"
anchor = Typed(expected_type=ObjectAnchor)
locked = Bool(allow_none=True)
defaultSize = Bool(allow_none=True)
_print = Bool(allow_none=True)
disabled = Bool(allow_none=True)
uiObject = Bool(allow_none=True)
autoFill = Bool(allow_none=True)
autoLine = Bool(allow_none=True)
autoPict = Bool(allow_none=True)
macro = String()
altText = String(allow_none=True)
dde = Bool(allow_none=True)
__elements__ = ('anchor',)
def __init__(self,
anchor=None,
locked=True,
defaultSize=True,
_print=True,
disabled=False,
uiObject=False,
autoFill=True,
autoLine=True,
autoPict=True,
###lfc macro=None,
altText=None,
dde=False,
):
self.anchor = anchor
self.locked = locked
self.defaultSize = defaultSize
self._print = _print
self.disabled = disabled
self.uiObject = uiObject
self.autoFill = autoFill
self.autoLine = autoLine
self.autoPict = autoPict
###lfc self.macro = macro
self.altText = altText
self.dde = dde
class OleObject(Serialisable):
tagname = "oleObject"
objectPr = Typed(expected_type=ObjectPr, allow_none=True)
progId = String(allow_none=True)
dvAspect = Set(values=(['DVASPECT_CONTENT', 'DVASPECT_ICON']))
link = String(allow_none=True)
oleUpdate = Set(values=(['OLEUPDATE_ALWAYS', 'OLEUPDATE_ONCALL']))
autoLoad = Bool(allow_none=True)
shapeId = Integer()
__elements__ = ('objectPr',)
def __init__(self,
objectPr=None,
progId=None,
dvAspect='DVASPECT_CONTENT',
link=None,
###LFC: oleUpdate=None,
oleUpdate='OLEUPDATE_ONCALL',
autoLoad=False,
shapeId=None,
):
self.objectPr = objectPr
self.progId = progId
self.dvAspect = dvAspect
self.link = link
self.oleUpdate = oleUpdate
self.autoLoad = autoLoad
self.shapeId = shapeId
### lfc: copied from control.py
class Choice(Serialisable):
"""Markup compatiblity choice"""
tagname = "choice"
oleObject = Typed(expected_type=OleObject)
Requires = String()
def __init__(self, oleObject=None, Requires=None):
self.oleObject = oleObject
class AlternateContent(Serialisable):
"""Markup AlternateContent
"""
tagname = "AlternateContent"
Choice = Typed(expected_type=Choice)
def __init__(self, Choice=None):
self.Choice = Choice
### lfc: EOF copied from control.py
class OleObjects(Serialisable):
tagname = "oleObjects"
AlternateContent = Sequence(expected_type=AlternateContent)
oleObject = Sequence(expected_type=OleObject)
__elements__ = ('oleObject',)
def __init__(self,
AlternateContent=None,
oleObject=(),
):
### lfc: if xml contains AlternateContent markup-compatibility/2006 get the choice from the alternate as the initial object
if AlternateContent:
for ac in AlternateContent:
pprint(vars(ac))
oleObject = [ac.Choice.oleObject for ac in AlternateContent]
self.oleObject = oleObject
### from 3.2.0 openpyxl/worksheet/ole.py
xml = """