Skip to content

Commit c2bcaeb

Browse files
committed
Upgrade the Excelize library version
- Add dash and fill fields in the ChartLine class - Add border field in the ChartMarker class - Add font field in the ChartLegend class - Add legend field in the ChartSeries class - Add new ChartDashType class - Support setting dash line and marker border type of charts - Support setting dash type of line charts - Support setting font for chart legends
1 parent 0bed37d commit c2bcaeb

File tree

6 files changed

+88
-41
lines changed

6 files changed

+88
-41
lines changed

excelize.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ def add_chart(self, sheet: str, cell: str, chart: Chart, **combo: Chart) -> None
779779
categories
780780
values
781781
fill
782+
legend
782783
line
783784
marker
784785
data_label
@@ -804,6 +805,9 @@ def add_chart(self, sheet: str, cell: str, chart: Chart, **combo: Chart) -> None
804805
fill: This set the format for the data series fill. The 'fill' property
805806
is optional
806807
808+
legend: This set the font of legend text for a data series. The 'legend'
809+
property is optional.
810+
807811
line: This sets the line format of the line chart. The 'line' property
808812
is optional and if it isn't supplied it will default style. The options
809813
that can be set are width and color. The range of width is 0.25pt -
@@ -837,6 +841,7 @@ def add_chart(self, sheet: str, cell: str, chart: Chart, **combo: Chart) -> None
837841
838842
position
839843
show_legend_key
844+
font
840845
841846
position: Set the position of the chart legend. The default legend
842847
position is bottom. The available positions are:
@@ -848,8 +853,13 @@ def add_chart(self, sheet: str, cell: str, chart: Chart, **combo: Chart) -> None
848853
right
849854
top_right
850855
851-
ShowLegendKey: Set the legend keys shall be shown in data labels. The default
852-
value is false.
856+
show_legend_key: Set the legend keys shall be shown in data labels.
857+
The default value is False.
858+
859+
font: Set the font properties of the chart legend text. The properties
860+
that can be set are the same as the font object that is used for cell
861+
formatting. The font family, size, color, bold, italic, underline, and
862+
strike properties can be set.
853863
854864
Set properties of the chart title. The properties that can be set are:
855865
@@ -983,7 +993,7 @@ def add_chart(self, sheet: str, cell: str, chart: Chart, **combo: Chart) -> None
983993
984994
reverse_order: Specifies that the categories or values on reverse order
985995
(orientation of the chart). The 'reverse_order' property is optional. The
986-
default value is false.
996+
default value is False.
987997
988998
maximum: Specifies that the fixed maximum, 0 is auto. The 'maximum'
989999
property is optional. The default value is auto.
@@ -1033,6 +1043,9 @@ def add_chart(self, sheet: str, cell: str, chart: Chart, **combo: Chart) -> None
10331043
Set chart size by 'dimension' property. The 'dimension' property is
10341044
optional. The default width is 480, and height is 260.
10351045
1046+
Set chart legend for all data series by 'legend' property. The 'legend'
1047+
property is optional.
1048+
10361049
Set the bubble size in all data series for the bubble chart or 3D bubble
10371050
chart by 'bubble_sizes' property. The 'bubble_sizes' property is
10381051
optional. The default width is 100, and the value should be great than 0
@@ -4938,7 +4951,7 @@ def set_sheet_visible(self, sheet: str, visible: bool, *very_hidden: bool) -> No
49384951
Set worksheet visible by given worksheet name. A workbook must contain
49394952
at least one visible worksheet. If the given worksheet has been
49404953
activated, this setting will be invalidated. The third optional
4941-
very_hidden parameter only works when visible was false.
4954+
very_hidden parameter only works when visible was False.
49424955
49434956
Args:
49444957
sheet (str): The worksheet name

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/xuri/excelize-py
33
go 1.23.0
44

55
require (
6-
github.com/xuri/excelize/v2 v2.9.2-0.20250705033143-4ac39a83f90d
7-
golang.org/x/image v0.27.0
6+
github.com/xuri/excelize/v2 v2.9.2-0.20250710001508-249b593d21b1
7+
golang.org/x/image v0.29.0
88
)
99

1010
require (
@@ -13,7 +13,7 @@ require (
1313
github.com/tiendc/go-deepcopy v1.6.1 // indirect
1414
github.com/xuri/efp v0.0.1 // indirect
1515
github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 // indirect
16-
golang.org/x/crypto v0.39.0 // indirect
17-
golang.org/x/net v0.41.0 // indirect
18-
golang.org/x/text v0.26.0 // indirect
16+
golang.org/x/crypto v0.40.0 // indirect
17+
golang.org/x/net v0.42.0 // indirect
18+
golang.org/x/text v0.27.0 // indirect
1919
)

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ github.com/tiendc/go-deepcopy v1.6.1 h1:uVRTItFeNHkMcLueHS7OCsxgxT9P8MzGB/taUa2Y
1313
github.com/tiendc/go-deepcopy v1.6.1/go.mod h1:toXoeQoUqXOOS/X4sKuiAoSk6elIdqc0pN7MTgOOo2I=
1414
github.com/xuri/efp v0.0.1 h1:fws5Rv3myXyYni8uwj2qKjVaRP30PdjeYe2Y6FDsCL8=
1515
github.com/xuri/efp v0.0.1/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
16-
github.com/xuri/excelize/v2 v2.9.2-0.20250705033143-4ac39a83f90d h1:lCQQkdCgvaObmTrw0vjzvUbH1CyJE9yHgcj1a7Y1MU0=
17-
github.com/xuri/excelize/v2 v2.9.2-0.20250705033143-4ac39a83f90d/go.mod h1:isQygQdjiU88/HpJYtp+6TN/FH29HvVjWT8vFk3t5+w=
16+
github.com/xuri/excelize/v2 v2.9.2-0.20250710001508-249b593d21b1 h1:wj8xnLX7FjRxN+ua4A+UEB0IzTQwlN6zTQ1atbUgQRM=
17+
github.com/xuri/excelize/v2 v2.9.2-0.20250710001508-249b593d21b1/go.mod h1:isQygQdjiU88/HpJYtp+6TN/FH29HvVjWT8vFk3t5+w=
1818
github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 h1:+C0TIdyyYmzadGaL/HBLbf3WdLgC29pgyhTjAT/0nuE=
1919
github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
20-
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
21-
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
22-
golang.org/x/image v0.27.0 h1:C8gA4oWU/tKkdCfYT6T2u4faJu3MeNS5O8UPWlPF61w=
23-
golang.org/x/image v0.27.0/go.mod h1:xbdrClrAUway1MUTEZDq9mz/UpRwYAkFFNUslZtcB+g=
24-
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
25-
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
26-
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
27-
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
20+
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
21+
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
22+
golang.org/x/image v0.29.0 h1:HcdsyR4Gsuys/Axh0rDEmlBmB68rW1U9BUdB3UVHsas=
23+
golang.org/x/image v0.29.0/go.mod h1:RVJROnf3SLK8d26OW91j4FrIHGbsJ8QnbEocVTOWQDA=
24+
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
25+
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
26+
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
27+
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
2828
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
2929
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

types_c.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -442,24 +442,28 @@ struct ChartLegend
442442
{
443443
char *Position;
444444
bool ShowLegendKey;
445-
};
446-
447-
// ChartMarker directly maps the format settings of the chart marker.
448-
struct ChartMarker
449-
{
450-
struct Fill Fill;
451-
char *Symbol;
452-
int Size;
445+
struct Font *Font;
453446
};
454447

455448
// ChartLine directly maps the format settings of the chart line.
456449
struct ChartLine
457450
{
458451
unsigned char Type;
452+
unsigned char Dash;
453+
struct Fill Fill;
459454
bool Smooth;
460455
double Width;
461456
};
462457

458+
// ChartMarker directly maps the format settings of the chart marker.
459+
struct ChartMarker
460+
{
461+
struct ChartLine Border;
462+
struct Fill Fill;
463+
char *Symbol;
464+
int Size;
465+
};
466+
463467
// ChartSeries directly maps the format settings of the chart series.
464468
struct ChartSeries
465469
{
@@ -468,6 +472,7 @@ struct ChartSeries
468472
char *Values;
469473
char *Sizes;
470474
struct Fill Fill;
475+
struct ChartLegend Legend;
471476
struct ChartLine Line;
472477
struct ChartMarker Marker;
473478
struct ChartDataLabel DataLabel;

types_go.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,22 +413,26 @@ class _ChartLegend(Structure):
413413
_fields_ = [
414414
("Position", c_char_p),
415415
("ShowLegendKey", c_bool),
416+
("Font", POINTER(_Font)),
416417
]
417418

418419

419-
class _ChartMarker(Structure):
420+
class _ChartLine(Structure):
420421
_fields_ = [
422+
("Type", c_uint),
423+
("Dash", c_uint),
421424
("Fill", _Fill),
422-
("Symbol", c_char_p),
423-
("Size", c_int),
425+
("Smooth", c_bool),
426+
("Width", c_double),
424427
]
425428

426429

427-
class _ChartLine(Structure):
430+
class _ChartMarker(Structure):
428431
_fields_ = [
429-
("Type", c_uint),
430-
("Smooth", c_bool),
431-
("Width", c_double),
432+
("Border", _ChartLine),
433+
("Fill", _Fill),
434+
("Symbol", c_char_p),
435+
("Size", c_int),
432436
]
433437

434438

@@ -439,6 +443,7 @@ class _ChartSeries(Structure):
439443
("Values", c_char_p),
440444
("Sizes", c_char_p),
441445
("Fill", _Fill),
446+
("Legend", _ChartLegend),
442447
("Line", _ChartLine),
443448
("Marker", _ChartMarker),
444449
("DataLabel", _ChartDataLabel),

types_py.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@ class FormControlType(IntEnum):
5959
FormControlScrollBar = 7
6060

6161

62+
class ChartDashType(IntEnum):
63+
"""
64+
ChartDashType defines the currently supported chart dash types enumeration.
65+
"""
66+
67+
ChartDashUnset = 0
68+
ChartDashSolid = 1
69+
ChartDashDot = 2
70+
ChartDashDash = 3
71+
ChartDashLgDash = 4
72+
ChartDashSashDot = 5
73+
ChartDashLgDashDot = 6
74+
ChartDashLgDashDotDot = 7
75+
ChartDashSysDash = 8
76+
ChartDashSysDot = 9
77+
ChartDashSysDashDot = 10
78+
ChartDashSysDashDotDot = 11
79+
80+
6281
class ChartLineType(IntEnum):
6382
"""
6483
ChartLineType defines the currently supported chart line types enumeration.
@@ -540,29 +559,34 @@ class ChartPlotArea:
540559
class ChartLegend:
541560
position: str = ""
542561
show_legend_key: bool = False
543-
544-
545-
@dataclass
546-
class ChartMarker:
547-
fill: Fill = Fill
548-
symbol: str = ""
549-
size: int = 0
562+
font: Optional[Font] = None
550563

551564

552565
@dataclass
553566
class ChartLine:
554567
type: ChartLineType = ChartLineType.ChartLineUnset
568+
dash: ChartDashType = ChartDashType.ChartDashUnset
569+
fill: Fill = Fill
555570
smooth: bool = False
556571
width: float = 0
557572

558573

574+
@dataclass
575+
class ChartMarker:
576+
border: ChartLine = ChartLine
577+
fill: Fill = Fill
578+
symbol: str = ""
579+
size: int = 0
580+
581+
559582
@dataclass
560583
class ChartSeries:
561584
name: str = ""
562585
categories: str = ""
563586
values: str = ""
564587
sizes: str = ""
565588
fill: Fill = Fill
589+
legend: ChartLegend = ChartLegend
566590
line: ChartLine = ChartLine
567591
marker: ChartMarker = ChartMarker
568592
data_label: ChartDataLabel = ChartDataLabel

0 commit comments

Comments
 (0)