Updated script that can be controled by Nodejs web app
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
# Copyright (c) 2010-2024 openpyxl
|
||||
|
||||
from .chartsheet import Chartsheet
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
107
lib/python3.13/site-packages/openpyxl/chartsheet/chartsheet.py
Normal file
107
lib/python3.13/site-packages/openpyxl/chartsheet/chartsheet.py
Normal file
@ -0,0 +1,107 @@
|
||||
# Copyright (c) 2010-2024 openpyxl
|
||||
|
||||
|
||||
from openpyxl.descriptors import Typed, Set, Alias
|
||||
from openpyxl.descriptors.excel import ExtensionList
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
from openpyxl.drawing.spreadsheet_drawing import (
|
||||
AbsoluteAnchor,
|
||||
SpreadsheetDrawing,
|
||||
)
|
||||
from openpyxl.worksheet.page import (
|
||||
PageMargins,
|
||||
PrintPageSetup
|
||||
)
|
||||
from openpyxl.worksheet.drawing import Drawing
|
||||
from openpyxl.worksheet.header_footer import HeaderFooter
|
||||
from openpyxl.workbook.child import _WorkbookChild
|
||||
from openpyxl.xml.constants import SHEET_MAIN_NS, REL_NS
|
||||
|
||||
from .relation import DrawingHF, SheetBackgroundPicture
|
||||
from .properties import ChartsheetProperties
|
||||
from .protection import ChartsheetProtection
|
||||
from .views import ChartsheetViewList
|
||||
from .custom import CustomChartsheetViews
|
||||
from .publish import WebPublishItems
|
||||
|
||||
|
||||
class Chartsheet(_WorkbookChild, Serialisable):
|
||||
|
||||
tagname = "chartsheet"
|
||||
_default_title = "Chart"
|
||||
_rel_type = "chartsheet"
|
||||
_path = "/xl/chartsheets/sheet{0}.xml"
|
||||
mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml"
|
||||
|
||||
sheetPr = Typed(expected_type=ChartsheetProperties, allow_none=True)
|
||||
sheetViews = Typed(expected_type=ChartsheetViewList)
|
||||
sheetProtection = Typed(expected_type=ChartsheetProtection, allow_none=True)
|
||||
customSheetViews = Typed(expected_type=CustomChartsheetViews, allow_none=True)
|
||||
pageMargins = Typed(expected_type=PageMargins, allow_none=True)
|
||||
pageSetup = Typed(expected_type=PrintPageSetup, allow_none=True)
|
||||
drawing = Typed(expected_type=Drawing, allow_none=True)
|
||||
drawingHF = Typed(expected_type=DrawingHF, allow_none=True)
|
||||
picture = Typed(expected_type=SheetBackgroundPicture, allow_none=True)
|
||||
webPublishItems = Typed(expected_type=WebPublishItems, allow_none=True)
|
||||
extLst = Typed(expected_type=ExtensionList, allow_none=True)
|
||||
sheet_state = Set(values=('visible', 'hidden', 'veryHidden'))
|
||||
headerFooter = Typed(expected_type=HeaderFooter)
|
||||
HeaderFooter = Alias('headerFooter')
|
||||
|
||||
__elements__ = (
|
||||
'sheetPr', 'sheetViews', 'sheetProtection', 'customSheetViews',
|
||||
'pageMargins', 'pageSetup', 'headerFooter', 'drawing', 'drawingHF',
|
||||
'picture', 'webPublishItems')
|
||||
|
||||
__attrs__ = ()
|
||||
|
||||
def __init__(self,
|
||||
sheetPr=None,
|
||||
sheetViews=None,
|
||||
sheetProtection=None,
|
||||
customSheetViews=None,
|
||||
pageMargins=None,
|
||||
pageSetup=None,
|
||||
headerFooter=None,
|
||||
drawing=None,
|
||||
drawingHF=None,
|
||||
picture=None,
|
||||
webPublishItems=None,
|
||||
extLst=None,
|
||||
parent=None,
|
||||
title="",
|
||||
sheet_state='visible',
|
||||
):
|
||||
super().__init__(parent, title)
|
||||
self._charts = []
|
||||
self.sheetPr = sheetPr
|
||||
if sheetViews is None:
|
||||
sheetViews = ChartsheetViewList()
|
||||
self.sheetViews = sheetViews
|
||||
self.sheetProtection = sheetProtection
|
||||
self.customSheetViews = customSheetViews
|
||||
self.pageMargins = pageMargins
|
||||
self.pageSetup = pageSetup
|
||||
if headerFooter is not None:
|
||||
self.headerFooter = headerFooter
|
||||
self.drawing = Drawing("rId1")
|
||||
self.drawingHF = drawingHF
|
||||
self.picture = picture
|
||||
self.webPublishItems = webPublishItems
|
||||
self.sheet_state = sheet_state
|
||||
|
||||
|
||||
def add_chart(self, chart):
|
||||
chart.anchor = AbsoluteAnchor()
|
||||
self._charts.append(chart)
|
||||
|
||||
|
||||
def to_tree(self):
|
||||
self._drawing = SpreadsheetDrawing()
|
||||
self._drawing.charts = self._charts
|
||||
tree = super().to_tree()
|
||||
if not self.headerFooter:
|
||||
el = tree.find('headerFooter')
|
||||
tree.remove(el)
|
||||
tree.set("xmlns", SHEET_MAIN_NS)
|
||||
return tree
|
61
lib/python3.13/site-packages/openpyxl/chartsheet/custom.py
Normal file
61
lib/python3.13/site-packages/openpyxl/chartsheet/custom.py
Normal file
@ -0,0 +1,61 @@
|
||||
# Copyright (c) 2010-2024 openpyxl
|
||||
|
||||
from openpyxl.worksheet.header_footer import HeaderFooter
|
||||
|
||||
from openpyxl.descriptors import (
|
||||
Bool,
|
||||
Integer,
|
||||
Set,
|
||||
Typed,
|
||||
Sequence
|
||||
)
|
||||
from openpyxl.descriptors.excel import Guid
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
from openpyxl.worksheet.page import (
|
||||
PageMargins,
|
||||
PrintPageSetup
|
||||
)
|
||||
|
||||
|
||||
class CustomChartsheetView(Serialisable):
|
||||
tagname = "customSheetView"
|
||||
|
||||
guid = Guid()
|
||||
scale = Integer()
|
||||
state = Set(values=(['visible', 'hidden', 'veryHidden']))
|
||||
zoomToFit = Bool(allow_none=True)
|
||||
pageMargins = Typed(expected_type=PageMargins, allow_none=True)
|
||||
pageSetup = Typed(expected_type=PrintPageSetup, allow_none=True)
|
||||
headerFooter = Typed(expected_type=HeaderFooter, allow_none=True)
|
||||
|
||||
__elements__ = ('pageMargins', 'pageSetup', 'headerFooter')
|
||||
|
||||
def __init__(self,
|
||||
guid=None,
|
||||
scale=None,
|
||||
state='visible',
|
||||
zoomToFit=None,
|
||||
pageMargins=None,
|
||||
pageSetup=None,
|
||||
headerFooter=None,
|
||||
):
|
||||
self.guid = guid
|
||||
self.scale = scale
|
||||
self.state = state
|
||||
self.zoomToFit = zoomToFit
|
||||
self.pageMargins = pageMargins
|
||||
self.pageSetup = pageSetup
|
||||
self.headerFooter = headerFooter
|
||||
|
||||
|
||||
class CustomChartsheetViews(Serialisable):
|
||||
tagname = "customSheetViews"
|
||||
|
||||
customSheetView = Sequence(expected_type=CustomChartsheetView, allow_none=True)
|
||||
|
||||
__elements__ = ('customSheetView',)
|
||||
|
||||
def __init__(self,
|
||||
customSheetView=None,
|
||||
):
|
||||
self.customSheetView = customSheetView
|
@ -0,0 +1,28 @@
|
||||
# Copyright (c) 2010-2024 openpyxl
|
||||
|
||||
from openpyxl.descriptors import (
|
||||
Bool,
|
||||
String,
|
||||
Typed
|
||||
)
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
from openpyxl.styles import Color
|
||||
|
||||
|
||||
class ChartsheetProperties(Serialisable):
|
||||
tagname = "sheetPr"
|
||||
|
||||
published = Bool(allow_none=True)
|
||||
codeName = String(allow_none=True)
|
||||
tabColor = Typed(expected_type=Color, allow_none=True)
|
||||
|
||||
__elements__ = ('tabColor',)
|
||||
|
||||
def __init__(self,
|
||||
published=None,
|
||||
codeName=None,
|
||||
tabColor=None,
|
||||
):
|
||||
self.published = published
|
||||
self.codeName = codeName
|
||||
self.tabColor = tabColor
|
@ -0,0 +1,41 @@
|
||||
import hashlib
|
||||
|
||||
from openpyxl.descriptors import (Bool, Integer, String)
|
||||
from openpyxl.descriptors.excel import Base64Binary
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
|
||||
from openpyxl.worksheet.protection import (
|
||||
hash_password,
|
||||
_Protected
|
||||
)
|
||||
|
||||
|
||||
class ChartsheetProtection(Serialisable, _Protected):
|
||||
tagname = "sheetProtection"
|
||||
|
||||
algorithmName = String(allow_none=True)
|
||||
hashValue = Base64Binary(allow_none=True)
|
||||
saltValue = Base64Binary(allow_none=True)
|
||||
spinCount = Integer(allow_none=True)
|
||||
content = Bool(allow_none=True)
|
||||
objects = Bool(allow_none=True)
|
||||
|
||||
__attrs__ = ("content", "objects", "password", "hashValue", "spinCount", "saltValue", "algorithmName")
|
||||
|
||||
def __init__(self,
|
||||
content=None,
|
||||
objects=None,
|
||||
hashValue=None,
|
||||
spinCount=None,
|
||||
saltValue=None,
|
||||
algorithmName=None,
|
||||
password=None,
|
||||
):
|
||||
self.content = content
|
||||
self.objects = objects
|
||||
self.hashValue = hashValue
|
||||
self.spinCount = spinCount
|
||||
self.saltValue = saltValue
|
||||
self.algorithmName = algorithmName
|
||||
if password is not None:
|
||||
self.password = password
|
58
lib/python3.13/site-packages/openpyxl/chartsheet/publish.py
Normal file
58
lib/python3.13/site-packages/openpyxl/chartsheet/publish.py
Normal file
@ -0,0 +1,58 @@
|
||||
# Copyright (c) 2010-2024 openpyxl
|
||||
|
||||
from openpyxl.descriptors import (
|
||||
Bool,
|
||||
Integer,
|
||||
String,
|
||||
Set,
|
||||
Sequence
|
||||
)
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
|
||||
|
||||
class WebPublishItem(Serialisable):
|
||||
tagname = "webPublishItem"
|
||||
|
||||
id = Integer()
|
||||
divId = String()
|
||||
sourceType = Set(values=(['sheet', 'printArea', 'autoFilter', 'range', 'chart', 'pivotTable', 'query', 'label']))
|
||||
sourceRef = String()
|
||||
sourceObject = String(allow_none=True)
|
||||
destinationFile = String()
|
||||
title = String(allow_none=True)
|
||||
autoRepublish = Bool(allow_none=True)
|
||||
|
||||
def __init__(self,
|
||||
id=None,
|
||||
divId=None,
|
||||
sourceType=None,
|
||||
sourceRef=None,
|
||||
sourceObject=None,
|
||||
destinationFile=None,
|
||||
title=None,
|
||||
autoRepublish=None,
|
||||
):
|
||||
self.id = id
|
||||
self.divId = divId
|
||||
self.sourceType = sourceType
|
||||
self.sourceRef = sourceRef
|
||||
self.sourceObject = sourceObject
|
||||
self.destinationFile = destinationFile
|
||||
self.title = title
|
||||
self.autoRepublish = autoRepublish
|
||||
|
||||
|
||||
class WebPublishItems(Serialisable):
|
||||
tagname = "WebPublishItems"
|
||||
|
||||
count = Integer(allow_none=True)
|
||||
webPublishItem = Sequence(expected_type=WebPublishItem, )
|
||||
|
||||
__elements__ = ('webPublishItem',)
|
||||
|
||||
def __init__(self,
|
||||
count=None,
|
||||
webPublishItem=None,
|
||||
):
|
||||
self.count = len(webPublishItem)
|
||||
self.webPublishItem = webPublishItem
|
97
lib/python3.13/site-packages/openpyxl/chartsheet/relation.py
Normal file
97
lib/python3.13/site-packages/openpyxl/chartsheet/relation.py
Normal file
@ -0,0 +1,97 @@
|
||||
# Copyright (c) 2010-2024 openpyxl
|
||||
|
||||
from openpyxl.descriptors import (
|
||||
Integer,
|
||||
Alias
|
||||
)
|
||||
from openpyxl.descriptors.excel import Relation
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
|
||||
|
||||
class SheetBackgroundPicture(Serialisable):
|
||||
tagname = "picture"
|
||||
id = Relation()
|
||||
|
||||
def __init__(self, id):
|
||||
self.id = id
|
||||
|
||||
|
||||
class DrawingHF(Serialisable):
|
||||
id = Relation()
|
||||
lho = Integer(allow_none=True)
|
||||
leftHeaderOddPages = Alias('lho')
|
||||
lhe = Integer(allow_none=True)
|
||||
leftHeaderEvenPages = Alias('lhe')
|
||||
lhf = Integer(allow_none=True)
|
||||
leftHeaderFirstPage = Alias('lhf')
|
||||
cho = Integer(allow_none=True)
|
||||
centerHeaderOddPages = Alias('cho')
|
||||
che = Integer(allow_none=True)
|
||||
centerHeaderEvenPages = Alias('che')
|
||||
chf = Integer(allow_none=True)
|
||||
centerHeaderFirstPage = Alias('chf')
|
||||
rho = Integer(allow_none=True)
|
||||
rightHeaderOddPages = Alias('rho')
|
||||
rhe = Integer(allow_none=True)
|
||||
rightHeaderEvenPages = Alias('rhe')
|
||||
rhf = Integer(allow_none=True)
|
||||
rightHeaderFirstPage = Alias('rhf')
|
||||
lfo = Integer(allow_none=True)
|
||||
leftFooterOddPages = Alias('lfo')
|
||||
lfe = Integer(allow_none=True)
|
||||
leftFooterEvenPages = Alias('lfe')
|
||||
lff = Integer(allow_none=True)
|
||||
leftFooterFirstPage = Alias('lff')
|
||||
cfo = Integer(allow_none=True)
|
||||
centerFooterOddPages = Alias('cfo')
|
||||
cfe = Integer(allow_none=True)
|
||||
centerFooterEvenPages = Alias('cfe')
|
||||
cff = Integer(allow_none=True)
|
||||
centerFooterFirstPage = Alias('cff')
|
||||
rfo = Integer(allow_none=True)
|
||||
rightFooterOddPages = Alias('rfo')
|
||||
rfe = Integer(allow_none=True)
|
||||
rightFooterEvenPages = Alias('rfe')
|
||||
rff = Integer(allow_none=True)
|
||||
rightFooterFirstPage = Alias('rff')
|
||||
|
||||
def __init__(self,
|
||||
id=None,
|
||||
lho=None,
|
||||
lhe=None,
|
||||
lhf=None,
|
||||
cho=None,
|
||||
che=None,
|
||||
chf=None,
|
||||
rho=None,
|
||||
rhe=None,
|
||||
rhf=None,
|
||||
lfo=None,
|
||||
lfe=None,
|
||||
lff=None,
|
||||
cfo=None,
|
||||
cfe=None,
|
||||
cff=None,
|
||||
rfo=None,
|
||||
rfe=None,
|
||||
rff=None,
|
||||
):
|
||||
self.id = id
|
||||
self.lho = lho
|
||||
self.lhe = lhe
|
||||
self.lhf = lhf
|
||||
self.cho = cho
|
||||
self.che = che
|
||||
self.chf = chf
|
||||
self.rho = rho
|
||||
self.rhe = rhe
|
||||
self.rhf = rhf
|
||||
self.lfo = lfo
|
||||
self.lfe = lfe
|
||||
self.lff = lff
|
||||
self.cfo = cfo
|
||||
self.cfe = cfe
|
||||
self.cff = cff
|
||||
self.rfo = rfo
|
||||
self.rfe = rfe
|
||||
self.rff = rff
|
51
lib/python3.13/site-packages/openpyxl/chartsheet/views.py
Normal file
51
lib/python3.13/site-packages/openpyxl/chartsheet/views.py
Normal file
@ -0,0 +1,51 @@
|
||||
# Copyright (c) 2010-2024 openpyxl
|
||||
|
||||
from openpyxl.descriptors import (
|
||||
Bool,
|
||||
Integer,
|
||||
Typed,
|
||||
Sequence
|
||||
)
|
||||
from openpyxl.descriptors.excel import ExtensionList
|
||||
from openpyxl.descriptors.serialisable import Serialisable
|
||||
|
||||
|
||||
class ChartsheetView(Serialisable):
|
||||
tagname = "sheetView"
|
||||
|
||||
tabSelected = Bool(allow_none=True)
|
||||
zoomScale = Integer(allow_none=True)
|
||||
workbookViewId = Integer()
|
||||
zoomToFit = Bool(allow_none=True)
|
||||
extLst = Typed(expected_type=ExtensionList, allow_none=True)
|
||||
|
||||
__elements__ = ()
|
||||
|
||||
def __init__(self,
|
||||
tabSelected=None,
|
||||
zoomScale=None,
|
||||
workbookViewId=0,
|
||||
zoomToFit=True,
|
||||
extLst=None,
|
||||
):
|
||||
self.tabSelected = tabSelected
|
||||
self.zoomScale = zoomScale
|
||||
self.workbookViewId = workbookViewId
|
||||
self.zoomToFit = zoomToFit
|
||||
|
||||
|
||||
class ChartsheetViewList(Serialisable):
|
||||
tagname = "sheetViews"
|
||||
|
||||
sheetView = Sequence(expected_type=ChartsheetView, )
|
||||
extLst = Typed(expected_type=ExtensionList, allow_none=True)
|
||||
|
||||
__elements__ = ('sheetView',)
|
||||
|
||||
def __init__(self,
|
||||
sheetView=None,
|
||||
extLst=None,
|
||||
):
|
||||
if sheetView is None:
|
||||
sheetView = [ChartsheetView()]
|
||||
self.sheetView = sheetView
|
Reference in New Issue
Block a user