Skip to content

Commit 834d53f

Browse files
committed
Add 4 stock chart support for add_chart and add_chart_sheet function
- Support create 4 kinds of box and whisker stock charts: "High-Low-Close", "Open-High-Low-Close", "Volume-High-Low-Close", "Volume-Open-High-Low-Close" - Add new ChartUpDownBar data type - Add 2 new fields up_bars and down_bars in the ChartPlotArea type - Upgrade the dependencies package version - Upgrade GitHub action tools version
1 parent 09b56ec commit 834d53f

File tree

7 files changed

+141
-110
lines changed

7 files changed

+141
-110
lines changed

.github/workflows/build.yml

Lines changed: 70 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ permissions:
55
pull-requests: write
66

77
jobs:
8-
98
test:
109
strategy:
1110
matrix:
@@ -17,54 +16,53 @@ jobs:
1716
runs-on: ${{ matrix.os }}
1817

1918
steps:
19+
- name: Install Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version: ${{ matrix.go-version }}
23+
cache: false
24+
25+
- name: Install Python
26+
uses: actions/setup-python@v6
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Checkout code
31+
uses: actions/checkout@v5
32+
33+
- name: Get dependencies
34+
run: |
35+
env GO111MODULE=on go vet ./...
36+
pip install coverage
37+
38+
- name: Build
39+
run: go build -v .
40+
41+
- name: Test on Windows
42+
env:
43+
CGO_ENABLED: 1
44+
if: matrix.os == 'windows-latest'
45+
run: go build -buildmode=c-shared -o libexcelize.amd64.windows.dll main.go && coverage run -m unittest
46+
47+
- name: Test on Linux
48+
env:
49+
CGO_ENABLED: 1
50+
if: matrix.os == 'ubuntu-24.04'
51+
run: go build -buildmode=c-shared -o libexcelize.amd64.linux.so main.go && coverage run -m unittest
52+
53+
- name: Test on macOS
54+
env:
55+
CGO_ENABLED: 1
56+
if: matrix.os == 'macos-latest'
57+
run: go build -buildmode=c-shared -o libexcelize.arm64.darwin.dylib main.go && coverage run -m unittest
2058

21-
- name: Install Go
22-
uses: actions/setup-go@v5
23-
with:
24-
go-version: ${{ matrix.go-version }}
25-
cache: false
26-
27-
- name: Install Python
28-
uses: actions/setup-python@v5
29-
with:
30-
python-version: ${{ matrix.python-version }}
31-
32-
- name: Checkout code
33-
uses: actions/checkout@v4
34-
35-
- name: Get dependencies
36-
run: |
37-
env GO111MODULE=on go vet ./...
38-
pip install coverage
39-
40-
- name: Build
41-
run: go build -v .
42-
43-
- name: Test on Windows
44-
env:
45-
CGO_ENABLED: 1
46-
if: matrix.os == 'windows-latest'
47-
run: go build -buildmode=c-shared -o libexcelize.amd64.windows.dll main.go && coverage run -m unittest
48-
49-
- name: Test on Linux
50-
env:
51-
CGO_ENABLED: 1
52-
if: matrix.os == 'ubuntu-24.04'
53-
run: go build -buildmode=c-shared -o libexcelize.amd64.linux.so main.go && coverage run -m unittest
54-
55-
- name: Test on macOS
56-
env:
57-
CGO_ENABLED: 1
58-
if: matrix.os == 'macos-latest'
59-
run: go build -buildmode=c-shared -o libexcelize.arm64.darwin.dylib main.go && coverage run -m unittest
60-
61-
- name: Codecov
62-
uses: codecov/codecov-action@v5
63-
env:
64-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
65-
with:
66-
flags: unittests
67-
name: codecov-umbrella
59+
- name: Codecov
60+
uses: codecov/codecov-action@v5
61+
env:
62+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
63+
with:
64+
flags: unittests
65+
name: codecov-umbrella
6866

6967
build:
7068
runs-on: ${{ matrix.os }}
@@ -75,20 +73,19 @@ jobs:
7573
os: [ubuntu-24.04, macos-latest]
7674

7775
steps:
78-
7976
- name: Install Go
8077
uses: actions/setup-go@v5
8178
with:
82-
go-version: 1.24.x
79+
go-version: 1.25.x
8380
cache: false
8481

8582
- name: Install Python
86-
uses: actions/setup-python@v5
83+
uses: actions/setup-python@v6
8784
with:
8885
python-version: "3.9"
8986

9087
- name: Checkout code
91-
uses: actions/checkout@v4
88+
uses: actions/checkout@v5
9289

9390
- name: Get dependencies
9491
run: |
@@ -155,24 +152,24 @@ jobs:
155152

156153
if: github.event_name == 'release' && github.event.action == 'published'
157154
steps:
158-
- name: Install Python
159-
uses: actions/setup-python@v5
160-
with:
161-
python-version: "3.9"
162-
163-
- name: Checkout code
164-
uses: actions/checkout@v4
165-
166-
- name: Download Artifacts
167-
uses: actions/download-artifact@v4
168-
with:
169-
merge-multiple: true
170-
path: ./
171-
172-
- name: Build Python Package
173-
run: |
174-
pip install build setuptools wheel
175-
python -m build
176-
177-
- name: Publish package distributions to PyPI
178-
uses: pypa/gh-action-pypi-publish@release/v1
155+
- name: Install Python
156+
uses: actions/setup-python@v6
157+
with:
158+
python-version: "3.9"
159+
160+
- name: Checkout code
161+
uses: actions/checkout@v5
162+
163+
- name: Download Artifacts
164+
uses: actions/download-artifact@v5
165+
with:
166+
merge-multiple: true
167+
path: ./
168+
169+
- name: Build Python Package
170+
run: |
171+
pip install build setuptools wheel
172+
python -m build
173+
174+
- name: Publish package distributions to PyPI
175+
uses: pypa/gh-action-pypi-publish@release/v1

excelize.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def c_value_to_py(ctypes_instance, py_instance):
250250
else c_array[i].contents.value
251251
)
252252
else:
253-
# Pointer array of the Go struct, for example: []*excelize.Options
253+
# Pointer array of the Go struct, for example: []*excelize.Options
254254
for i in range(l):
255255
py_list.append(
256256
c_value_to_py(
@@ -419,7 +419,7 @@ def py_value_to_c(py_instance, ctypes_instance):
419419
py_to_base_ctype(py_list[i], c_type)
420420
)
421421
else:
422-
# Pointer array of the Go struct, for example: []*excelize.Options
422+
# Pointer array of the Go struct, for example: []*excelize.Options
423423
for i in range(l):
424424
c_array[i] = pointer(
425425
py_value_to_c(py_list[i], c_type())
@@ -835,6 +835,8 @@ def add_chart(self, sheet: str, cell: str, chart: Chart, **combo: Chart) -> None
835835
| 52 | WireframeContour | Wireframe contour chart |
836836
| 53 | Bubble | Bubble chart |
837837
| 54 | Bubble3D | 3D bubble chart |
838+
| 55 | StockHighLowClose | High-Low-Close stock chart |
839+
| 56 | StockOpenHighLowClose | Open-High-Low-Close stock chart |
838840
839841
In Excel a chart series is a collection of information that defines
840842
which data is plotted such as values, axis labels and formatting.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/xuri/excelize-py
33
go 1.23.0
44

55
require (
6-
github.com/xuri/excelize/v2 v2.9.2-0.20250819233021-845a2746d755
6+
github.com/xuri/excelize/v2 v2.9.2-0.20250904030645-aca295923b09
77
golang.org/x/image v0.30.0
88
)
99

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ 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.20250819233021-845a2746d755 h1:iEw4Ruca4g+xm/+BO6l7TKWYmc4vIAJ7j7VXuLWfQuQ=
17-
github.com/xuri/excelize/v2 v2.9.2-0.20250819233021-845a2746d755/go.mod h1:kJNWyr0LiVxr4LZiOJiN9w8t177/VpVsR4GIXvgzoAc=
16+
github.com/xuri/excelize/v2 v2.9.2-0.20250904030645-aca295923b09 h1:DJYS6eCwMDWmqyUBqSr5zEvMUy+SLXMT9r2H9k7J15U=
17+
github.com/xuri/excelize/v2 v2.9.2-0.20250904030645-aca295923b09/go.mod h1:kJNWyr0LiVxr4LZiOJiN9w8t177/VpVsR4GIXvgzoAc=
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=
2020
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=

types_c.h

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,24 @@ struct ChartDimension
422422
unsigned int Height;
423423
};
424424

425+
// ChartLine directly maps the format settings of the chart line.
426+
struct ChartLine
427+
{
428+
unsigned char Type;
429+
unsigned char Dash;
430+
struct Fill Fill;
431+
bool Smooth;
432+
double Width;
433+
};
434+
435+
// ChartUpDownBar directly maps the format settings of the stock chart up bars
436+
// and down bars.
437+
struct ChartUpDownBar
438+
{
439+
struct Fill Fill;
440+
struct ChartLine Border;
441+
};
442+
425443
// ChartPlotArea directly maps the format settings of the plot area.
426444
struct ChartPlotArea
427445
{
@@ -435,6 +453,8 @@ struct ChartPlotArea
435453
bool ShowSerName;
436454
bool ShowVal;
437455
struct Fill Fill;
456+
struct ChartUpDownBar UpBars;
457+
struct ChartUpDownBar DownBars;
438458
struct ChartNumFmt NumFmt;
439459
};
440460

@@ -446,16 +466,6 @@ struct ChartLegend
446466
struct Font *Font;
447467
};
448468

449-
// ChartLine directly maps the format settings of the chart line.
450-
struct ChartLine
451-
{
452-
unsigned char Type;
453-
unsigned char Dash;
454-
struct Fill Fill;
455-
bool Smooth;
456-
double Width;
457-
};
458-
459469
// ChartMarker directly maps the format settings of the chart marker.
460470
struct ChartMarker
461471
{
@@ -754,7 +764,8 @@ struct StringArrayErrorResult
754764
char *Err;
755765
};
756766

757-
struct IntStringResult {
767+
struct IntStringResult
768+
{
758769
int K;
759770
char *V;
760771
};
@@ -824,13 +835,15 @@ struct GetSheetPropsResult
824835
char *err;
825836
};
826837

827-
struct GetSheetMapResult {
838+
struct GetSheetMapResult
839+
{
828840
int ArrLen;
829841
struct IntStringResult *Arr;
830842
char *Err;
831843
};
832844

833-
struct GetCommentsResult {
845+
struct GetCommentsResult
846+
{
834847
int CommentsLen;
835848
struct Comment *Comments;
836849
char *Err;

types_go.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,23 @@ class _ChartDimension(Structure):
394394
]
395395

396396

397+
class _ChartLine(Structure):
398+
_fields_ = [
399+
("Type", c_uint),
400+
("Dash", c_uint),
401+
("Fill", _Fill),
402+
("Smooth", c_bool),
403+
("Width", c_double),
404+
]
405+
406+
407+
class _ChartUpDownBar(Structure):
408+
_fields_ = [
409+
("Fill", _Fill),
410+
("Border", _ChartLine),
411+
]
412+
413+
397414
class _ChartPlotArea(Structure):
398415
_fields_ = [
399416
("SecondPlotValues", c_int),
@@ -406,6 +423,8 @@ class _ChartPlotArea(Structure):
406423
("ShowSerName", c_bool),
407424
("ShowVal", c_bool),
408425
("Fill", _Fill),
426+
("UpBars", _ChartUpDownBar),
427+
("DownBars", _ChartUpDownBar),
409428
("NumFmt", _ChartNumFmt),
410429
]
411430

@@ -418,16 +437,6 @@ class _ChartLegend(Structure):
418437
]
419438

420439

421-
class _ChartLine(Structure):
422-
_fields_ = [
423-
("Type", c_uint),
424-
("Dash", c_uint),
425-
("Fill", _Fill),
426-
("Smooth", c_bool),
427-
("Width", c_double),
428-
]
429-
430-
431440
class _ChartMarker(Structure):
432441
_fields_ = [
433442
("Border", _ChartLine),

0 commit comments

Comments
 (0)