@v587d/capital-generation 2.28.0 → 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +5 -4
- package/THIRD_PARTY_NOTICES.md +16 -0
- package/automation/package.json +1 -1
- package/chart-ui/package.json +1 -1
- package/config/package.json +1 -1
- package/lib/collector-runtime.js +56 -1
- package/lib/data-collector/catalog-taxonomy.d.ts +1 -1
- package/lib/data-collector/catalog-taxonomy.js +33 -0
- package/lib/data-collector/tools.js +7 -7
- package/lib/host-version.d.ts +9 -0
- package/lib/host-version.js +57 -0
- package/lib/python-runtime/errors.d.ts +1 -1
- package/lib/python-runtime/errors.js +2 -0
- package/lib/python-runtime/manager.d.ts +28 -1
- package/lib/python-runtime/manager.js +141 -5
- package/lib/python-runtime/probe.d.ts +24 -0
- package/lib/python-runtime/probe.js +66 -50
- package/lib/runtime-entry.js +8 -0
- package/lib/sources/csindex-http.d.ts +4 -0
- package/lib/sources/csindex-http.js +233 -0
- package/lib/sources/eastmoney-http.js +1504 -1
- package/lib/sources/fuyao-rest.js +168 -8
- package/lib/sources/official-http.d.ts +4 -0
- package/lib/sources/official-http.js +477 -0
- package/lib/sources/python-remote.d.ts +25 -0
- package/lib/sources/python-remote.js +461 -0
- package/lib/sources/sina-http.d.ts +2 -0
- package/lib/sources/sina-http.js +484 -0
- package/lib/sources/tencent-http.js +23 -8
- package/lib/sources/ths-http.d.ts +2 -0
- package/lib/sources/ths-http.js +514 -0
- package/lib/time/tools.js +19 -0
- package/lib/web-retriever/local-fetch.d.ts +1 -1
- package/lib/web-retriever/local-fetch.js +1 -1
- package/lib/web-retriever/sources.d.ts +7 -0
- package/lib/web-retriever/sources.js +46 -21
- package/lib/web-retriever/throttle.d.ts +8 -0
- package/lib/web-retriever/throttle.js +13 -0
- package/lib/web-retriever/tools.js +1 -1
- package/lib/web-retriever/wind-client.d.ts +1 -1
- package/lib/web-retriever/wind-client.js +1 -1
- package/package.json +6 -3
- package/preset/capital-generation/agent.patch.yml +7 -5
- package/preset/capital-generation/skills/capital-data-protocol/SKILL.md +16 -16
- package/python/scripts/baostock_stock_basic.py +129 -0
- package/python/scripts/baostock_valuation_history.py +141 -0
- package/python/scripts/pbc_social_financing.py +291 -0
- package/python/vendor/baostock/LICENSE +19 -0
- package/python/vendor/baostock/__init__.py +42 -0
- package/python/vendor/baostock/common/__init__.py +0 -0
- package/python/vendor/baostock/common/contants.py +189 -0
- package/python/vendor/baostock/common/context.py +4 -0
- package/python/vendor/baostock/corpreport/__init__.py +0 -0
- package/python/vendor/baostock/corpreport/corp_performance.py +202 -0
- package/python/vendor/baostock/data/__init__.py +0 -0
- package/python/vendor/baostock/data/messageheader.py +17 -0
- package/python/vendor/baostock/data/msg.py +21 -0
- package/python/vendor/baostock/data/resultset.py +200 -0
- package/python/vendor/baostock/demo/__init__.py +0 -0
- package/python/vendor/baostock/demo/demo_A_stock_5mk-data.py +34 -0
- package/python/vendor/baostock/demo/demo_A_stock_k_data.py +36 -0
- package/python/vendor/baostock/demo/demo_AllStock.py +27 -0
- package/python/vendor/baostock/demo/demo_Balance_data.py +22 -0
- package/python/vendor/baostock/demo/demo_CashFlow_data.py +22 -0
- package/python/vendor/baostock/demo/demo_Dividend_data.py +35 -0
- package/python/vendor/baostock/demo/demo_Dupont_data.py +25 -0
- package/python/vendor/baostock/demo/demo_Forecast_report.py +24 -0
- package/python/vendor/baostock/demo/demo_Growth_data.py +22 -0
- package/python/vendor/baostock/demo/demo_Index_k_data.py +39 -0
- package/python/vendor/baostock/demo/demo_Operation_data.py +22 -0
- package/python/vendor/baostock/demo/demo_PerformanceExpress_report.py +25 -0
- package/python/vendor/baostock/demo/demo_Profit_data.py +22 -0
- package/python/vendor/baostock/demo/demo_TradeDates.py +27 -0
- package/python/vendor/baostock/demo/demo_adjust_factor_data.py +23 -0
- package/python/vendor/baostock/demo/demo_assignDayData.py +23 -0
- package/python/vendor/baostock/demo/demo_daily_adjust_factor_data.py +28 -0
- package/python/vendor/baostock/demo/demo_daily_k_4_AStock.py +28 -0
- package/python/vendor/baostock/demo/demo_daily_k_4_ETF.py +28 -0
- package/python/vendor/baostock/demo/demo_depositRate_data.py +26 -0
- package/python/vendor/baostock/demo/demo_hs300_stocks.py +26 -0
- package/python/vendor/baostock/demo/demo_loanRate_data.py +26 -0
- package/python/vendor/baostock/demo/demo_moneySupplyDataMonth_data.py +26 -0
- package/python/vendor/baostock/demo/demo_moneySupplyDataYear_data.py +26 -0
- package/python/vendor/baostock/demo/demo_requiredReserveRatio_data.py +26 -0
- package/python/vendor/baostock/demo/demo_set_API_key.py +37 -0
- package/python/vendor/baostock/demo/demo_stockBasic_data.py +27 -0
- package/python/vendor/baostock/demo/demo_stock_Valuation_indicator_data.py +34 -0
- package/python/vendor/baostock/demo/demo_stock_industry.py +26 -0
- package/python/vendor/baostock/demo/demo_sz50stocks.py +26 -0
- package/python/vendor/baostock/demo/demo_zz500_stock.py +26 -0
- package/python/vendor/baostock/evaluation/__init__.py +0 -0
- package/python/vendor/baostock/evaluation/season_index.py +758 -0
- package/python/vendor/baostock/login/__init__.py +0 -0
- package/python/vendor/baostock/login/loginout.py +230 -0
- package/python/vendor/baostock/macroscopic/__init__.py +0 -0
- package/python/vendor/baostock/macroscopic/economic_data.py +723 -0
- package/python/vendor/baostock/metadata/__init__.py +0 -0
- package/python/vendor/baostock/metadata/stock_metadata.py +207 -0
- package/python/vendor/baostock/security/__init__.py +0 -0
- package/python/vendor/baostock/security/history.py +265 -0
- package/python/vendor/baostock/security/sectorinfo.py +1024 -0
- package/python/vendor/baostock/util/__init__.py +0 -0
- package/python/vendor/baostock/util/socketutil.py +97 -0
- package/python/vendor/baostock/util/stringutil.py +83 -0
- package/python/vendor/et_xmlfile/LICENSE +23 -0
- package/python/vendor/et_xmlfile/LICENSE.python +298 -0
- package/python/vendor/et_xmlfile/__init__.py +8 -0
- package/python/vendor/et_xmlfile/incremental_tree.py +917 -0
- package/python/vendor/et_xmlfile/xmlfile.py +158 -0
- package/python/vendor/openpyxl/LICENSE +23 -0
- package/python/vendor/openpyxl/__init__.py +19 -0
- package/python/vendor/openpyxl/_constants.py +13 -0
- package/python/vendor/openpyxl/cell/__init__.py +4 -0
- package/python/vendor/openpyxl/cell/_writer.py +136 -0
- package/python/vendor/openpyxl/cell/cell.py +332 -0
- package/python/vendor/openpyxl/cell/read_only.py +136 -0
- package/python/vendor/openpyxl/cell/rich_text.py +202 -0
- package/python/vendor/openpyxl/cell/text.py +184 -0
- package/python/vendor/openpyxl/chart/_3d.py +105 -0
- package/python/vendor/openpyxl/chart/__init__.py +19 -0
- package/python/vendor/openpyxl/chart/_chart.py +199 -0
- package/python/vendor/openpyxl/chart/area_chart.py +106 -0
- package/python/vendor/openpyxl/chart/axis.py +401 -0
- package/python/vendor/openpyxl/chart/bar_chart.py +144 -0
- package/python/vendor/openpyxl/chart/bubble_chart.py +67 -0
- package/python/vendor/openpyxl/chart/chartspace.py +195 -0
- package/python/vendor/openpyxl/chart/data_source.py +246 -0
- package/python/vendor/openpyxl/chart/descriptors.py +43 -0
- package/python/vendor/openpyxl/chart/error_bar.py +62 -0
- package/python/vendor/openpyxl/chart/label.py +127 -0
- package/python/vendor/openpyxl/chart/layout.py +74 -0
- package/python/vendor/openpyxl/chart/legend.py +75 -0
- package/python/vendor/openpyxl/chart/line_chart.py +129 -0
- package/python/vendor/openpyxl/chart/marker.py +90 -0
- package/python/vendor/openpyxl/chart/picture.py +35 -0
- package/python/vendor/openpyxl/chart/pie_chart.py +177 -0
- package/python/vendor/openpyxl/chart/pivot.py +65 -0
- package/python/vendor/openpyxl/chart/plotarea.py +162 -0
- package/python/vendor/openpyxl/chart/print_settings.py +57 -0
- package/python/vendor/openpyxl/chart/radar_chart.py +55 -0
- package/python/vendor/openpyxl/chart/reader.py +32 -0
- package/python/vendor/openpyxl/chart/reference.py +124 -0
- package/python/vendor/openpyxl/chart/scatter_chart.py +53 -0
- package/python/vendor/openpyxl/chart/series.py +197 -0
- package/python/vendor/openpyxl/chart/series_factory.py +41 -0
- package/python/vendor/openpyxl/chart/shapes.py +89 -0
- package/python/vendor/openpyxl/chart/stock_chart.py +54 -0
- package/python/vendor/openpyxl/chart/surface_chart.py +119 -0
- package/python/vendor/openpyxl/chart/text.py +78 -0
- package/python/vendor/openpyxl/chart/title.py +76 -0
- package/python/vendor/openpyxl/chart/trendline.py +98 -0
- package/python/vendor/openpyxl/chart/updown_bars.py +31 -0
- package/python/vendor/openpyxl/chartsheet/__init__.py +3 -0
- package/python/vendor/openpyxl/chartsheet/chartsheet.py +107 -0
- package/python/vendor/openpyxl/chartsheet/custom.py +61 -0
- package/python/vendor/openpyxl/chartsheet/properties.py +28 -0
- package/python/vendor/openpyxl/chartsheet/protection.py +41 -0
- package/python/vendor/openpyxl/chartsheet/publish.py +58 -0
- package/python/vendor/openpyxl/chartsheet/relation.py +97 -0
- package/python/vendor/openpyxl/chartsheet/views.py +51 -0
- package/python/vendor/openpyxl/comments/__init__.py +4 -0
- package/python/vendor/openpyxl/comments/author.py +21 -0
- package/python/vendor/openpyxl/comments/comment_sheet.py +211 -0
- package/python/vendor/openpyxl/comments/comments.py +62 -0
- package/python/vendor/openpyxl/comments/shape_writer.py +112 -0
- package/python/vendor/openpyxl/compat/__init__.py +54 -0
- package/python/vendor/openpyxl/compat/abc.py +8 -0
- package/python/vendor/openpyxl/compat/numbers.py +43 -0
- package/python/vendor/openpyxl/compat/product.py +17 -0
- package/python/vendor/openpyxl/compat/singleton.py +40 -0
- package/python/vendor/openpyxl/compat/strings.py +25 -0
- package/python/vendor/openpyxl/descriptors/__init__.py +58 -0
- package/python/vendor/openpyxl/descriptors/base.py +272 -0
- package/python/vendor/openpyxl/descriptors/container.py +41 -0
- package/python/vendor/openpyxl/descriptors/excel.py +112 -0
- package/python/vendor/openpyxl/descriptors/namespace.py +12 -0
- package/python/vendor/openpyxl/descriptors/nested.py +129 -0
- package/python/vendor/openpyxl/descriptors/sequence.py +136 -0
- package/python/vendor/openpyxl/descriptors/serialisable.py +240 -0
- package/python/vendor/openpyxl/descriptors/slots.py +18 -0
- package/python/vendor/openpyxl/drawing/__init__.py +4 -0
- package/python/vendor/openpyxl/drawing/colors.py +435 -0
- package/python/vendor/openpyxl/drawing/connector.py +144 -0
- package/python/vendor/openpyxl/drawing/drawing.py +92 -0
- package/python/vendor/openpyxl/drawing/effect.py +407 -0
- package/python/vendor/openpyxl/drawing/fill.py +425 -0
- package/python/vendor/openpyxl/drawing/geometry.py +584 -0
- package/python/vendor/openpyxl/drawing/graphic.py +177 -0
- package/python/vendor/openpyxl/drawing/image.py +65 -0
- package/python/vendor/openpyxl/drawing/line.py +144 -0
- package/python/vendor/openpyxl/drawing/picture.py +144 -0
- package/python/vendor/openpyxl/drawing/properties.py +174 -0
- package/python/vendor/openpyxl/drawing/relation.py +17 -0
- package/python/vendor/openpyxl/drawing/spreadsheet_drawing.py +382 -0
- package/python/vendor/openpyxl/drawing/text.py +717 -0
- package/python/vendor/openpyxl/drawing/xdr.py +33 -0
- package/python/vendor/openpyxl/formatting/__init__.py +3 -0
- package/python/vendor/openpyxl/formatting/formatting.py +114 -0
- package/python/vendor/openpyxl/formatting/rule.py +291 -0
- package/python/vendor/openpyxl/formula/__init__.py +3 -0
- package/python/vendor/openpyxl/formula/tokenizer.py +446 -0
- package/python/vendor/openpyxl/formula/translate.py +166 -0
- package/python/vendor/openpyxl/packaging/__init__.py +3 -0
- package/python/vendor/openpyxl/packaging/core.py +115 -0
- package/python/vendor/openpyxl/packaging/custom.py +289 -0
- package/python/vendor/openpyxl/packaging/extended.py +137 -0
- package/python/vendor/openpyxl/packaging/interface.py +56 -0
- package/python/vendor/openpyxl/packaging/manifest.py +194 -0
- package/python/vendor/openpyxl/packaging/relationship.py +158 -0
- package/python/vendor/openpyxl/packaging/workbook.py +185 -0
- package/python/vendor/openpyxl/pivot/__init__.py +1 -0
- package/python/vendor/openpyxl/pivot/cache.py +965 -0
- package/python/vendor/openpyxl/pivot/fields.py +326 -0
- package/python/vendor/openpyxl/pivot/record.py +111 -0
- package/python/vendor/openpyxl/pivot/table.py +1261 -0
- package/python/vendor/openpyxl/reader/__init__.py +1 -0
- package/python/vendor/openpyxl/reader/drawings.py +71 -0
- package/python/vendor/openpyxl/reader/excel.py +349 -0
- package/python/vendor/openpyxl/reader/strings.py +44 -0
- package/python/vendor/openpyxl/reader/workbook.py +133 -0
- package/python/vendor/openpyxl/styles/__init__.py +11 -0
- package/python/vendor/openpyxl/styles/alignment.py +62 -0
- package/python/vendor/openpyxl/styles/borders.py +103 -0
- package/python/vendor/openpyxl/styles/builtins.py +1397 -0
- package/python/vendor/openpyxl/styles/cell_style.py +206 -0
- package/python/vendor/openpyxl/styles/colors.py +172 -0
- package/python/vendor/openpyxl/styles/differential.py +95 -0
- package/python/vendor/openpyxl/styles/fills.py +224 -0
- package/python/vendor/openpyxl/styles/fonts.py +113 -0
- package/python/vendor/openpyxl/styles/named_styles.py +282 -0
- package/python/vendor/openpyxl/styles/numbers.py +200 -0
- package/python/vendor/openpyxl/styles/protection.py +17 -0
- package/python/vendor/openpyxl/styles/proxy.py +62 -0
- package/python/vendor/openpyxl/styles/styleable.py +151 -0
- package/python/vendor/openpyxl/styles/stylesheet.py +274 -0
- package/python/vendor/openpyxl/styles/table.py +94 -0
- package/python/vendor/openpyxl/utils/__init__.py +17 -0
- package/python/vendor/openpyxl/utils/bound_dictionary.py +26 -0
- package/python/vendor/openpyxl/utils/cell.py +240 -0
- package/python/vendor/openpyxl/utils/dataframe.py +87 -0
- package/python/vendor/openpyxl/utils/datetime.py +140 -0
- package/python/vendor/openpyxl/utils/escape.py +43 -0
- package/python/vendor/openpyxl/utils/exceptions.py +34 -0
- package/python/vendor/openpyxl/utils/formulas.py +24 -0
- package/python/vendor/openpyxl/utils/indexed_list.py +49 -0
- package/python/vendor/openpyxl/utils/inference.py +60 -0
- package/python/vendor/openpyxl/utils/protection.py +22 -0
- package/python/vendor/openpyxl/utils/units.py +108 -0
- package/python/vendor/openpyxl/workbook/__init__.py +4 -0
- package/python/vendor/openpyxl/workbook/_writer.py +197 -0
- package/python/vendor/openpyxl/workbook/child.py +166 -0
- package/python/vendor/openpyxl/workbook/defined_name.py +189 -0
- package/python/vendor/openpyxl/workbook/external_link/__init__.py +3 -0
- package/python/vendor/openpyxl/workbook/external_link/external.py +190 -0
- package/python/vendor/openpyxl/workbook/external_reference.py +18 -0
- package/python/vendor/openpyxl/workbook/function_group.py +36 -0
- package/python/vendor/openpyxl/workbook/properties.py +151 -0
- package/python/vendor/openpyxl/workbook/protection.py +163 -0
- package/python/vendor/openpyxl/workbook/smart_tags.py +56 -0
- package/python/vendor/openpyxl/workbook/views.py +155 -0
- package/python/vendor/openpyxl/workbook/web.py +98 -0
- package/python/vendor/openpyxl/workbook/workbook.py +438 -0
- package/python/vendor/openpyxl/worksheet/__init__.py +1 -0
- package/python/vendor/openpyxl/worksheet/_read_only.py +190 -0
- package/python/vendor/openpyxl/worksheet/_reader.py +472 -0
- package/python/vendor/openpyxl/worksheet/_write_only.py +160 -0
- package/python/vendor/openpyxl/worksheet/_writer.py +390 -0
- package/python/vendor/openpyxl/worksheet/cell_range.py +512 -0
- package/python/vendor/openpyxl/worksheet/cell_watch.py +34 -0
- package/python/vendor/openpyxl/worksheet/controls.py +107 -0
- package/python/vendor/openpyxl/worksheet/copier.py +70 -0
- package/python/vendor/openpyxl/worksheet/custom.py +35 -0
- package/python/vendor/openpyxl/worksheet/datavalidation.py +202 -0
- package/python/vendor/openpyxl/worksheet/dimensions.py +306 -0
- package/python/vendor/openpyxl/worksheet/drawing.py +14 -0
- package/python/vendor/openpyxl/worksheet/errors.py +93 -0
- package/python/vendor/openpyxl/worksheet/filters.py +486 -0
- package/python/vendor/openpyxl/worksheet/formula.py +51 -0
- package/python/vendor/openpyxl/worksheet/header_footer.py +270 -0
- package/python/vendor/openpyxl/worksheet/hyperlink.py +46 -0
- package/python/vendor/openpyxl/worksheet/merge.py +141 -0
- package/python/vendor/openpyxl/worksheet/ole.py +133 -0
- package/python/vendor/openpyxl/worksheet/page.py +174 -0
- package/python/vendor/openpyxl/worksheet/pagebreak.py +94 -0
- package/python/vendor/openpyxl/worksheet/picture.py +8 -0
- package/python/vendor/openpyxl/worksheet/print_settings.py +184 -0
- package/python/vendor/openpyxl/worksheet/properties.py +97 -0
- package/python/vendor/openpyxl/worksheet/protection.py +120 -0
- package/python/vendor/openpyxl/worksheet/related.py +17 -0
- package/python/vendor/openpyxl/worksheet/scenario.py +105 -0
- package/python/vendor/openpyxl/worksheet/smart_tag.py +78 -0
- package/python/vendor/openpyxl/worksheet/table.py +385 -0
- package/python/vendor/openpyxl/worksheet/views.py +155 -0
- package/python/vendor/openpyxl/worksheet/worksheet.py +907 -0
- package/python/vendor/openpyxl/writer/__init__.py +1 -0
- package/python/vendor/openpyxl/writer/excel.py +295 -0
- package/python/vendor/openpyxl/writer/theme.py +291 -0
- package/python/vendor/openpyxl/xml/__init__.py +42 -0
- package/python/vendor/openpyxl/xml/constants.py +129 -0
- package/python/vendor/openpyxl/xml/functions.py +87 -0
- package/watchlist/package.json +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
from openpyxl.descriptors import (
|
|
5
|
+
Alias,
|
|
6
|
+
Sequence,
|
|
7
|
+
Integer
|
|
8
|
+
)
|
|
9
|
+
from openpyxl.descriptors.serialisable import Serialisable
|
|
10
|
+
|
|
11
|
+
from openpyxl.descriptors.nested import (
|
|
12
|
+
NestedValue,
|
|
13
|
+
NestedBool,
|
|
14
|
+
NestedNoneSet,
|
|
15
|
+
NestedMinMax,
|
|
16
|
+
NestedString,
|
|
17
|
+
NestedInteger,
|
|
18
|
+
NestedFloat,
|
|
19
|
+
)
|
|
20
|
+
from .colors import ColorDescriptor, Color, BLACK
|
|
21
|
+
|
|
22
|
+
from openpyxl.compat import safe_string
|
|
23
|
+
from openpyxl.xml.functions import Element, SubElement
|
|
24
|
+
from openpyxl.xml.constants import SHEET_MAIN_NS
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _no_value(tagname, value, namespace=None):
|
|
28
|
+
if value:
|
|
29
|
+
return Element(tagname, val=safe_string(value))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Font(Serialisable):
|
|
33
|
+
"""Font options used in styles."""
|
|
34
|
+
|
|
35
|
+
UNDERLINE_DOUBLE = 'double'
|
|
36
|
+
UNDERLINE_DOUBLE_ACCOUNTING = 'doubleAccounting'
|
|
37
|
+
UNDERLINE_SINGLE = 'single'
|
|
38
|
+
UNDERLINE_SINGLE_ACCOUNTING = 'singleAccounting'
|
|
39
|
+
|
|
40
|
+
name = NestedString(allow_none=True)
|
|
41
|
+
charset = NestedInteger(allow_none=True)
|
|
42
|
+
family = NestedMinMax(min=0, max=14, allow_none=True)
|
|
43
|
+
sz = NestedFloat(allow_none=True)
|
|
44
|
+
size = Alias("sz")
|
|
45
|
+
b = NestedBool(to_tree=_no_value)
|
|
46
|
+
bold = Alias("b")
|
|
47
|
+
i = NestedBool(to_tree=_no_value)
|
|
48
|
+
italic = Alias("i")
|
|
49
|
+
strike = NestedBool(allow_none=True)
|
|
50
|
+
strikethrough = Alias("strike")
|
|
51
|
+
outline = NestedBool(allow_none=True)
|
|
52
|
+
shadow = NestedBool(allow_none=True)
|
|
53
|
+
condense = NestedBool(allow_none=True)
|
|
54
|
+
extend = NestedBool(allow_none=True)
|
|
55
|
+
u = NestedNoneSet(values=('single', 'double', 'singleAccounting',
|
|
56
|
+
'doubleAccounting'))
|
|
57
|
+
underline = Alias("u")
|
|
58
|
+
vertAlign = NestedNoneSet(values=('superscript', 'subscript', 'baseline'))
|
|
59
|
+
color = ColorDescriptor(allow_none=True)
|
|
60
|
+
scheme = NestedNoneSet(values=("major", "minor"))
|
|
61
|
+
|
|
62
|
+
tagname = "font"
|
|
63
|
+
|
|
64
|
+
__elements__ = ('name', 'charset', 'family', 'b', 'i', 'strike', 'outline',
|
|
65
|
+
'shadow', 'condense', 'color', 'extend', 'sz', 'u', 'vertAlign',
|
|
66
|
+
'scheme')
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def __init__(self, name=None, sz=None, b=None, i=None, charset=None,
|
|
70
|
+
u=None, strike=None, color=None, scheme=None, family=None, size=None,
|
|
71
|
+
bold=None, italic=None, strikethrough=None, underline=None,
|
|
72
|
+
vertAlign=None, outline=None, shadow=None, condense=None,
|
|
73
|
+
extend=None):
|
|
74
|
+
self.name = name
|
|
75
|
+
self.family = family
|
|
76
|
+
if size is not None:
|
|
77
|
+
sz = size
|
|
78
|
+
self.sz = sz
|
|
79
|
+
if bold is not None:
|
|
80
|
+
b = bold
|
|
81
|
+
self.b = b
|
|
82
|
+
if italic is not None:
|
|
83
|
+
i = italic
|
|
84
|
+
self.i = i
|
|
85
|
+
if underline is not None:
|
|
86
|
+
u = underline
|
|
87
|
+
self.u = u
|
|
88
|
+
if strikethrough is not None:
|
|
89
|
+
strike = strikethrough
|
|
90
|
+
self.strike = strike
|
|
91
|
+
self.color = color
|
|
92
|
+
self.vertAlign = vertAlign
|
|
93
|
+
self.charset = charset
|
|
94
|
+
self.outline = outline
|
|
95
|
+
self.shadow = shadow
|
|
96
|
+
self.condense = condense
|
|
97
|
+
self.extend = extend
|
|
98
|
+
self.scheme = scheme
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@classmethod
|
|
102
|
+
def from_tree(cls, node):
|
|
103
|
+
"""
|
|
104
|
+
Set default value for underline if child element is present
|
|
105
|
+
"""
|
|
106
|
+
underline = node.find("{%s}u" % SHEET_MAIN_NS)
|
|
107
|
+
if underline is not None and underline.get('val') is None:
|
|
108
|
+
underline.set("val", "single")
|
|
109
|
+
return super().from_tree(node)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
DEFAULT_FONT = Font(name="Calibri", sz=11, family=2, b=False, i=False,
|
|
113
|
+
color=Color(theme=1), scheme="minor")
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
from openpyxl.compat import safe_string
|
|
4
|
+
|
|
5
|
+
from openpyxl.descriptors import (
|
|
6
|
+
Typed,
|
|
7
|
+
Integer,
|
|
8
|
+
Bool,
|
|
9
|
+
String,
|
|
10
|
+
Sequence,
|
|
11
|
+
)
|
|
12
|
+
from openpyxl.descriptors.excel import ExtensionList
|
|
13
|
+
from openpyxl.descriptors.serialisable import Serialisable
|
|
14
|
+
|
|
15
|
+
from .fills import PatternFill, Fill
|
|
16
|
+
from .fonts import Font
|
|
17
|
+
from .borders import Border
|
|
18
|
+
from .alignment import Alignment
|
|
19
|
+
from .protection import Protection
|
|
20
|
+
from .numbers import (
|
|
21
|
+
NumberFormatDescriptor,
|
|
22
|
+
BUILTIN_FORMATS_MAX_SIZE,
|
|
23
|
+
BUILTIN_FORMATS_REVERSE,
|
|
24
|
+
)
|
|
25
|
+
from .cell_style import (
|
|
26
|
+
StyleArray,
|
|
27
|
+
CellStyle,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class NamedStyle(Serialisable):
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
Named and editable styles
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
font = Typed(expected_type=Font)
|
|
38
|
+
fill = Typed(expected_type=Fill)
|
|
39
|
+
border = Typed(expected_type=Border)
|
|
40
|
+
alignment = Typed(expected_type=Alignment)
|
|
41
|
+
number_format = NumberFormatDescriptor()
|
|
42
|
+
protection = Typed(expected_type=Protection)
|
|
43
|
+
builtinId = Integer(allow_none=True)
|
|
44
|
+
hidden = Bool(allow_none=True)
|
|
45
|
+
name = String()
|
|
46
|
+
_wb = None
|
|
47
|
+
_style = StyleArray()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def __init__(self,
|
|
51
|
+
name="Normal",
|
|
52
|
+
font=None,
|
|
53
|
+
fill=None,
|
|
54
|
+
border=None,
|
|
55
|
+
alignment=None,
|
|
56
|
+
number_format=None,
|
|
57
|
+
protection=None,
|
|
58
|
+
builtinId=None,
|
|
59
|
+
hidden=False,
|
|
60
|
+
):
|
|
61
|
+
self.name = name
|
|
62
|
+
self.font = font or Font()
|
|
63
|
+
self.fill = fill or PatternFill()
|
|
64
|
+
self.border = border or Border()
|
|
65
|
+
self.alignment = alignment or Alignment()
|
|
66
|
+
self.number_format = number_format
|
|
67
|
+
self.protection = protection or Protection()
|
|
68
|
+
self.builtinId = builtinId
|
|
69
|
+
self.hidden = hidden
|
|
70
|
+
self._wb = None
|
|
71
|
+
self._style = StyleArray()
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def __setattr__(self, attr, value):
|
|
75
|
+
super().__setattr__(attr, value)
|
|
76
|
+
if getattr(self, '_wb', None) and attr in (
|
|
77
|
+
'font', 'fill', 'border', 'alignment', 'number_format', 'protection',
|
|
78
|
+
):
|
|
79
|
+
self._recalculate()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def __iter__(self):
|
|
83
|
+
for key in ('name', 'builtinId', 'hidden', 'xfId'):
|
|
84
|
+
value = getattr(self, key, None)
|
|
85
|
+
if value is not None:
|
|
86
|
+
yield key, safe_string(value)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def bind(self, wb):
|
|
90
|
+
"""
|
|
91
|
+
Bind a named style to a workbook
|
|
92
|
+
"""
|
|
93
|
+
self._wb = wb
|
|
94
|
+
self._recalculate()
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _recalculate(self):
|
|
98
|
+
self._style.fontId = self._wb._fonts.add(self.font)
|
|
99
|
+
self._style.borderId = self._wb._borders.add(self.border)
|
|
100
|
+
self._style.fillId = self._wb._fills.add(self.fill)
|
|
101
|
+
self._style.protectionId = self._wb._protections.add(self.protection)
|
|
102
|
+
self._style.alignmentId = self._wb._alignments.add(self.alignment)
|
|
103
|
+
fmt = self.number_format
|
|
104
|
+
if fmt in BUILTIN_FORMATS_REVERSE:
|
|
105
|
+
fmt = BUILTIN_FORMATS_REVERSE[fmt]
|
|
106
|
+
else:
|
|
107
|
+
fmt = self._wb._number_formats.add(self.number_format) + (
|
|
108
|
+
BUILTIN_FORMATS_MAX_SIZE)
|
|
109
|
+
self._style.numFmtId = fmt
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def as_tuple(self):
|
|
113
|
+
"""Return a style array representing the current style"""
|
|
114
|
+
return self._style
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def as_xf(self):
|
|
118
|
+
"""
|
|
119
|
+
Return equivalent XfStyle
|
|
120
|
+
"""
|
|
121
|
+
xf = CellStyle.from_array(self._style)
|
|
122
|
+
xf.xfId = None
|
|
123
|
+
xf.pivotButton = None
|
|
124
|
+
xf.quotePrefix = None
|
|
125
|
+
if self.alignment != Alignment():
|
|
126
|
+
xf.alignment = self.alignment
|
|
127
|
+
if self.protection != Protection():
|
|
128
|
+
xf.protection = self.protection
|
|
129
|
+
return xf
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def as_name(self):
|
|
133
|
+
"""
|
|
134
|
+
Return relevant named style
|
|
135
|
+
|
|
136
|
+
"""
|
|
137
|
+
named = _NamedCellStyle(
|
|
138
|
+
name=self.name,
|
|
139
|
+
builtinId=self.builtinId,
|
|
140
|
+
hidden=self.hidden,
|
|
141
|
+
xfId=self._style.xfId
|
|
142
|
+
)
|
|
143
|
+
return named
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class NamedStyleList(list):
|
|
147
|
+
"""
|
|
148
|
+
Named styles are editable and can be applied to multiple objects
|
|
149
|
+
|
|
150
|
+
As only the index is stored in referencing objects the order mus
|
|
151
|
+
be preserved.
|
|
152
|
+
|
|
153
|
+
Returns a list of NamedStyles
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
def __init__(self, iterable=()):
|
|
157
|
+
"""
|
|
158
|
+
Allow a list of named styles to be passed in and index them.
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
for idx, s in enumerate(iterable, len(self)):
|
|
162
|
+
s._style.xfId = idx
|
|
163
|
+
super().__init__(iterable)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@property
|
|
167
|
+
def names(self):
|
|
168
|
+
return [s.name for s in self]
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def __getitem__(self, key):
|
|
172
|
+
if isinstance(key, int):
|
|
173
|
+
return super().__getitem__(key)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
for idx, name in enumerate(self.names):
|
|
177
|
+
if name == key:
|
|
178
|
+
return self[idx]
|
|
179
|
+
|
|
180
|
+
raise KeyError("No named style with the name{0} exists".format(key))
|
|
181
|
+
|
|
182
|
+
def append(self, style):
|
|
183
|
+
if not isinstance(style, NamedStyle):
|
|
184
|
+
raise TypeError("""Only NamedStyle instances can be added""")
|
|
185
|
+
elif style.name in self.names: # hotspot
|
|
186
|
+
raise ValueError("""Style {0} exists already""".format(style.name))
|
|
187
|
+
style._style.xfId = (len(self))
|
|
188
|
+
super().append(style)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
class _NamedCellStyle(Serialisable):
|
|
192
|
+
|
|
193
|
+
"""
|
|
194
|
+
Pointer-based representation of named styles in XML
|
|
195
|
+
xfId refers to the corresponding CellStyleXfs
|
|
196
|
+
|
|
197
|
+
Not used in client code.
|
|
198
|
+
"""
|
|
199
|
+
|
|
200
|
+
tagname = "cellStyle"
|
|
201
|
+
|
|
202
|
+
name = String()
|
|
203
|
+
xfId = Integer()
|
|
204
|
+
builtinId = Integer(allow_none=True)
|
|
205
|
+
iLevel = Integer(allow_none=True)
|
|
206
|
+
hidden = Bool(allow_none=True)
|
|
207
|
+
customBuiltin = Bool(allow_none=True)
|
|
208
|
+
extLst = Typed(expected_type=ExtensionList, allow_none=True)
|
|
209
|
+
|
|
210
|
+
__elements__ = ()
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def __init__(self,
|
|
214
|
+
name=None,
|
|
215
|
+
xfId=None,
|
|
216
|
+
builtinId=None,
|
|
217
|
+
iLevel=None,
|
|
218
|
+
hidden=None,
|
|
219
|
+
customBuiltin=None,
|
|
220
|
+
extLst=None,
|
|
221
|
+
):
|
|
222
|
+
self.name = name
|
|
223
|
+
self.xfId = xfId
|
|
224
|
+
self.builtinId = builtinId
|
|
225
|
+
self.iLevel = iLevel
|
|
226
|
+
self.hidden = hidden
|
|
227
|
+
self.customBuiltin = customBuiltin
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
class _NamedCellStyleList(Serialisable):
|
|
231
|
+
"""
|
|
232
|
+
Container for named cell style objects
|
|
233
|
+
|
|
234
|
+
Not used in client code
|
|
235
|
+
"""
|
|
236
|
+
|
|
237
|
+
tagname = "cellStyles"
|
|
238
|
+
|
|
239
|
+
count = Integer(allow_none=True)
|
|
240
|
+
cellStyle = Sequence(expected_type=_NamedCellStyle)
|
|
241
|
+
|
|
242
|
+
__attrs__ = ("count",)
|
|
243
|
+
|
|
244
|
+
def __init__(self,
|
|
245
|
+
count=None,
|
|
246
|
+
cellStyle=(),
|
|
247
|
+
):
|
|
248
|
+
self.cellStyle = cellStyle
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
@property
|
|
252
|
+
def count(self):
|
|
253
|
+
return len(self.cellStyle)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def remove_duplicates(self):
|
|
257
|
+
"""
|
|
258
|
+
Some applications contain duplicate definitions either by name or
|
|
259
|
+
referenced style.
|
|
260
|
+
|
|
261
|
+
As the references are 0-based indices, styles are sorted by
|
|
262
|
+
index.
|
|
263
|
+
|
|
264
|
+
Returns a list of style references with duplicates removed
|
|
265
|
+
"""
|
|
266
|
+
|
|
267
|
+
def sort_fn(v):
|
|
268
|
+
return v.xfId
|
|
269
|
+
|
|
270
|
+
styles = []
|
|
271
|
+
names = set()
|
|
272
|
+
ids = set()
|
|
273
|
+
|
|
274
|
+
for ns in sorted(self.cellStyle, key=sort_fn):
|
|
275
|
+
if ns.xfId in ids or ns.name in names: # skip duplicates
|
|
276
|
+
continue
|
|
277
|
+
ids.add(ns.xfId)
|
|
278
|
+
names.add(ns.name)
|
|
279
|
+
|
|
280
|
+
styles.append(ns)
|
|
281
|
+
|
|
282
|
+
return styles
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
from openpyxl.descriptors import (
|
|
6
|
+
String,
|
|
7
|
+
Sequence,
|
|
8
|
+
Integer,
|
|
9
|
+
)
|
|
10
|
+
from openpyxl.descriptors.serialisable import Serialisable
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
BUILTIN_FORMATS = {
|
|
14
|
+
0: 'General',
|
|
15
|
+
1: '0',
|
|
16
|
+
2: '0.00',
|
|
17
|
+
3: '#,##0',
|
|
18
|
+
4: '#,##0.00',
|
|
19
|
+
5: '"$"#,##0_);("$"#,##0)',
|
|
20
|
+
6: '"$"#,##0_);[Red]("$"#,##0)',
|
|
21
|
+
7: '"$"#,##0.00_);("$"#,##0.00)',
|
|
22
|
+
8: '"$"#,##0.00_);[Red]("$"#,##0.00)',
|
|
23
|
+
9: '0%',
|
|
24
|
+
10: '0.00%',
|
|
25
|
+
11: '0.00E+00',
|
|
26
|
+
12: '# ?/?',
|
|
27
|
+
13: '# ??/??',
|
|
28
|
+
14: 'mm-dd-yy',
|
|
29
|
+
15: 'd-mmm-yy',
|
|
30
|
+
16: 'd-mmm',
|
|
31
|
+
17: 'mmm-yy',
|
|
32
|
+
18: 'h:mm AM/PM',
|
|
33
|
+
19: 'h:mm:ss AM/PM',
|
|
34
|
+
20: 'h:mm',
|
|
35
|
+
21: 'h:mm:ss',
|
|
36
|
+
22: 'm/d/yy h:mm',
|
|
37
|
+
|
|
38
|
+
37: '#,##0_);(#,##0)',
|
|
39
|
+
38: '#,##0_);[Red](#,##0)',
|
|
40
|
+
39: '#,##0.00_);(#,##0.00)',
|
|
41
|
+
40: '#,##0.00_);[Red](#,##0.00)',
|
|
42
|
+
|
|
43
|
+
41: r'_(* #,##0_);_(* \(#,##0\);_(* "-"_);_(@_)',
|
|
44
|
+
42: r'_("$"* #,##0_);_("$"* \(#,##0\);_("$"* "-"_);_(@_)',
|
|
45
|
+
43: r'_(* #,##0.00_);_(* \(#,##0.00\);_(* "-"??_);_(@_)',
|
|
46
|
+
|
|
47
|
+
44: r'_("$"* #,##0.00_)_("$"* \(#,##0.00\)_("$"* "-"??_)_(@_)',
|
|
48
|
+
45: 'mm:ss',
|
|
49
|
+
46: '[h]:mm:ss',
|
|
50
|
+
47: 'mmss.0',
|
|
51
|
+
48: '##0.0E+0',
|
|
52
|
+
49: '@', }
|
|
53
|
+
|
|
54
|
+
BUILTIN_FORMATS_MAX_SIZE = 164
|
|
55
|
+
BUILTIN_FORMATS_REVERSE = dict(
|
|
56
|
+
[(value, key) for key, value in BUILTIN_FORMATS.items()])
|
|
57
|
+
|
|
58
|
+
FORMAT_GENERAL = BUILTIN_FORMATS[0]
|
|
59
|
+
FORMAT_TEXT = BUILTIN_FORMATS[49]
|
|
60
|
+
FORMAT_NUMBER = BUILTIN_FORMATS[1]
|
|
61
|
+
FORMAT_NUMBER_00 = BUILTIN_FORMATS[2]
|
|
62
|
+
FORMAT_NUMBER_COMMA_SEPARATED1 = BUILTIN_FORMATS[4]
|
|
63
|
+
FORMAT_NUMBER_COMMA_SEPARATED2 = '#,##0.00_-'
|
|
64
|
+
FORMAT_PERCENTAGE = BUILTIN_FORMATS[9]
|
|
65
|
+
FORMAT_PERCENTAGE_00 = BUILTIN_FORMATS[10]
|
|
66
|
+
FORMAT_DATE_YYYYMMDD2 = 'yyyy-mm-dd'
|
|
67
|
+
FORMAT_DATE_YYMMDD = 'yy-mm-dd'
|
|
68
|
+
FORMAT_DATE_DDMMYY = 'dd/mm/yy'
|
|
69
|
+
FORMAT_DATE_DMYSLASH = 'd/m/y'
|
|
70
|
+
FORMAT_DATE_DMYMINUS = 'd-m-y'
|
|
71
|
+
FORMAT_DATE_DMMINUS = 'd-m'
|
|
72
|
+
FORMAT_DATE_MYMINUS = 'm-y'
|
|
73
|
+
FORMAT_DATE_XLSX14 = BUILTIN_FORMATS[14]
|
|
74
|
+
FORMAT_DATE_XLSX15 = BUILTIN_FORMATS[15]
|
|
75
|
+
FORMAT_DATE_XLSX16 = BUILTIN_FORMATS[16]
|
|
76
|
+
FORMAT_DATE_XLSX17 = BUILTIN_FORMATS[17]
|
|
77
|
+
FORMAT_DATE_XLSX22 = BUILTIN_FORMATS[22]
|
|
78
|
+
FORMAT_DATE_DATETIME = 'yyyy-mm-dd h:mm:ss'
|
|
79
|
+
FORMAT_DATE_TIME1 = BUILTIN_FORMATS[18]
|
|
80
|
+
FORMAT_DATE_TIME2 = BUILTIN_FORMATS[19]
|
|
81
|
+
FORMAT_DATE_TIME3 = BUILTIN_FORMATS[20]
|
|
82
|
+
FORMAT_DATE_TIME4 = BUILTIN_FORMATS[21]
|
|
83
|
+
FORMAT_DATE_TIME5 = BUILTIN_FORMATS[45]
|
|
84
|
+
FORMAT_DATE_TIME6 = BUILTIN_FORMATS[21]
|
|
85
|
+
FORMAT_DATE_TIME7 = 'i:s.S'
|
|
86
|
+
FORMAT_DATE_TIME8 = 'h:mm:ss@'
|
|
87
|
+
FORMAT_DATE_TIMEDELTA = '[hh]:mm:ss'
|
|
88
|
+
FORMAT_DATE_YYMMDDSLASH = 'yy/mm/dd@'
|
|
89
|
+
FORMAT_CURRENCY_USD_SIMPLE = '"$"#,##0.00_-'
|
|
90
|
+
FORMAT_CURRENCY_USD = '$#,##0_-'
|
|
91
|
+
FORMAT_CURRENCY_EUR_SIMPLE = '[$EUR ]#,##0.00_-'
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
COLORS = r"\[(BLACK|BLUE|CYAN|GREEN|MAGENTA|RED|WHITE|YELLOW)\]"
|
|
95
|
+
LITERAL_GROUP = r'".*?"' # anything in quotes
|
|
96
|
+
LOCALE_GROUP = r'\[(?!hh?\]|mm?\]|ss?\])[^\]]*\]' # anything in square brackets, except hours or minutes or seconds
|
|
97
|
+
STRIP_RE = re.compile(f"{LITERAL_GROUP}|{LOCALE_GROUP}")
|
|
98
|
+
TIMEDELTA_RE = re.compile(r'\[hh?\](:mm(:ss(\.0*)?)?)?|\[mm?\](:ss(\.0*)?)?|\[ss?\](\.0*)?', re.I)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
# Spec 18.8.31 numFmts
|
|
102
|
+
# +ve;-ve;zero;text
|
|
103
|
+
|
|
104
|
+
def is_date_format(fmt):
|
|
105
|
+
if fmt is None:
|
|
106
|
+
return False
|
|
107
|
+
fmt = fmt.split(";")[0] # only look at the first format
|
|
108
|
+
fmt = STRIP_RE.sub("", fmt) # ignore some formats
|
|
109
|
+
return re.search(r"(?<![_\\])[dmhysDMHYS]", fmt) is not None
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def is_timedelta_format(fmt):
|
|
113
|
+
if fmt is None:
|
|
114
|
+
return False
|
|
115
|
+
fmt = fmt.split(";")[0] # only look at the first format
|
|
116
|
+
return TIMEDELTA_RE.search(fmt) is not None
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def is_datetime(fmt):
|
|
120
|
+
"""
|
|
121
|
+
Return date, time or datetime
|
|
122
|
+
"""
|
|
123
|
+
if not is_date_format(fmt):
|
|
124
|
+
return
|
|
125
|
+
|
|
126
|
+
DATE = TIME = False
|
|
127
|
+
|
|
128
|
+
if any((x in fmt for x in 'dy')):
|
|
129
|
+
DATE = True
|
|
130
|
+
if any((x in fmt for x in 'hs')):
|
|
131
|
+
TIME = True
|
|
132
|
+
|
|
133
|
+
if DATE and TIME:
|
|
134
|
+
return "datetime"
|
|
135
|
+
if DATE:
|
|
136
|
+
return "date"
|
|
137
|
+
return "time"
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def is_builtin(fmt):
|
|
141
|
+
return fmt in BUILTIN_FORMATS.values()
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def builtin_format_code(index):
|
|
145
|
+
"""Return one of the standard format codes by index."""
|
|
146
|
+
try:
|
|
147
|
+
fmt = BUILTIN_FORMATS[index]
|
|
148
|
+
except KeyError:
|
|
149
|
+
fmt = None
|
|
150
|
+
return fmt
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def builtin_format_id(fmt):
|
|
154
|
+
"""Return the id of a standard style."""
|
|
155
|
+
return BUILTIN_FORMATS_REVERSE.get(fmt)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class NumberFormatDescriptor(String):
|
|
159
|
+
|
|
160
|
+
def __set__(self, instance, value):
|
|
161
|
+
if value is None:
|
|
162
|
+
value = FORMAT_GENERAL
|
|
163
|
+
super().__set__(instance, value)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class NumberFormat(Serialisable):
|
|
167
|
+
|
|
168
|
+
numFmtId = Integer()
|
|
169
|
+
formatCode = String()
|
|
170
|
+
|
|
171
|
+
def __init__(self,
|
|
172
|
+
numFmtId=None,
|
|
173
|
+
formatCode=None,
|
|
174
|
+
):
|
|
175
|
+
self.numFmtId = numFmtId
|
|
176
|
+
self.formatCode = formatCode
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class NumberFormatList(Serialisable):
|
|
180
|
+
|
|
181
|
+
count = Integer(allow_none=True)
|
|
182
|
+
numFmt = Sequence(expected_type=NumberFormat)
|
|
183
|
+
|
|
184
|
+
__elements__ = ('numFmt',)
|
|
185
|
+
__attrs__ = ("count",)
|
|
186
|
+
|
|
187
|
+
def __init__(self,
|
|
188
|
+
count=None,
|
|
189
|
+
numFmt=(),
|
|
190
|
+
):
|
|
191
|
+
self.numFmt = numFmt
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
@property
|
|
195
|
+
def count(self):
|
|
196
|
+
return len(self.numFmt)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def __getitem__(self, idx):
|
|
200
|
+
return self.numFmt[idx]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
from openpyxl.descriptors import Bool
|
|
4
|
+
from openpyxl.descriptors.serialisable import Serialisable
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Protection(Serialisable):
|
|
8
|
+
"""Protection options for use in styles."""
|
|
9
|
+
|
|
10
|
+
tagname = "protection"
|
|
11
|
+
|
|
12
|
+
locked = Bool()
|
|
13
|
+
hidden = Bool()
|
|
14
|
+
|
|
15
|
+
def __init__(self, locked=True, hidden=False):
|
|
16
|
+
self.locked = locked
|
|
17
|
+
self.hidden = hidden
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Copyright (c) 2010-2024 openpyxl
|
|
2
|
+
|
|
3
|
+
from copy import copy
|
|
4
|
+
|
|
5
|
+
from openpyxl.compat import deprecated
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class StyleProxy:
|
|
9
|
+
"""
|
|
10
|
+
Proxy formatting objects so that they cannot be altered
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
__slots__ = ('__target')
|
|
14
|
+
|
|
15
|
+
def __init__(self, target):
|
|
16
|
+
self.__target = target
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def __repr__(self):
|
|
20
|
+
return repr(self.__target)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def __getattr__(self, attr):
|
|
24
|
+
return getattr(self.__target, attr)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def __setattr__(self, attr, value):
|
|
28
|
+
if attr != "_StyleProxy__target":
|
|
29
|
+
raise AttributeError("Style objects are immutable and cannot be changed."
|
|
30
|
+
"Reassign the style with a copy")
|
|
31
|
+
super().__setattr__(attr, value)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def __copy__(self):
|
|
35
|
+
"""
|
|
36
|
+
Return a copy of the proxied object.
|
|
37
|
+
"""
|
|
38
|
+
return copy(self.__target)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def __add__(self, other):
|
|
42
|
+
"""
|
|
43
|
+
Add proxied object to another instance and return the combined object
|
|
44
|
+
"""
|
|
45
|
+
return self.__target + other
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@deprecated("Use copy(obj) or cell.obj = cell.obj + other")
|
|
49
|
+
def copy(self, **kw):
|
|
50
|
+
"""Return a copy of the proxied object. Keyword args will be passed through"""
|
|
51
|
+
cp = copy(self.__target)
|
|
52
|
+
for k, v in kw.items():
|
|
53
|
+
setattr(cp, k, v)
|
|
54
|
+
return cp
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def __eq__(self, other):
|
|
58
|
+
return self.__target == other
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def __ne__(self, other):
|
|
62
|
+
return not self == other
|