Skip to content

Commit 97c6bf4

Browse files
committed
This closes #7, build shared library on Linux to fix invalid ELF header
- Add support for working with 32 bits Python on 64 bits Windows - Add show_data_table and show_data_table_keys fields in the ChartPlotArea class - Bump v0.0.4 - Update documentation for the add_form_control - Upgrade the dependencies package version
1 parent 035a0f8 commit 97c6bf4

File tree

7 files changed

+185
-44
lines changed

7 files changed

+185
-44
lines changed

.github/workflows/build.yml

+38-19
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ jobs:
6464
name: codecov-umbrella
6565

6666
build:
67-
runs-on: macos-latest
67+
runs-on: ${{ matrix.os }}
6868
needs: [test]
6969
if: github.event_name == 'release' && github.event.action == 'published'
70+
strategy:
71+
matrix:
72+
os: [ubuntu-24.04, macos-latest]
7073

7174
steps:
7275

@@ -93,28 +96,44 @@ jobs:
9396
env:
9497
CGO_ENABLED: 1
9598
run: |
96-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
97-
brew tap messense/macos-cross-toolchains
98-
brew install FiloSottile/musl-cross/musl-cross i686-unknown-linux-gnu mingw-w64
99-
wget https://github.com/mstorsjo/llvm-mingw/releases/download/20250114/llvm-mingw-20250114-ucrt-macos-universal.tar.xz
100-
tar -xzf llvm-mingw-20250114-ucrt-macos-universal.tar.xz
101-
export PATH="$(pwd)/llvm-mingw-20250114-ucrt-macos-universal/bin:$PATH"
102-
CC=i686-linux-gnu-gcc GOOS=linux GOARCH=386 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.386.linux.so main.go
103-
CC=x86_64-linux-musl-gcc GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.amd64.linux.so main.go
104-
CC=aarch64-linux-musl-gcc GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.arm64.linux.so main.go
105-
CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.amd64.windows.dll main.go
106-
CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.386.windows.dll main.go
107-
CC=aarch64-w64-mingw32-gcc GOOS=windows GOARCH=arm64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.arm64.windows.dll main.go
108-
CC=gcc GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.arm64.darwin.dylib main.go
109-
CC=gcc GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.amd64.darwin.dylib main.go
110-
rm -f libexcelize.*.h
111-
112-
- uses: actions/upload-artifact@v4
99+
if [[ "$RUNNER_OS" == "Linux" ]]; then
100+
sudo dpkg --add-architecture i386
101+
sudo apt update
102+
sudo apt install -y gcc-multilib g++-multilib libc6-dev-i386
103+
CC="gcc -m32" GOOS=linux GOARCH=386 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.386.linux.so main.go
104+
GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.amd64.linux.so main.go
105+
rm -f libexcelize.*.h
106+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
107+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
108+
brew tap messense/macos-cross-toolchains
109+
brew install FiloSottile/musl-cross/musl-cross mingw-w64
110+
wget https://github.com/mstorsjo/llvm-mingw/releases/download/20250430/llvm-mingw-20250430-ucrt-macos-universal.tar.xz
111+
tar -xzf llvm-mingw-20250430-ucrt-macos-universal.tar.xz
112+
export PATH="$(pwd)/llvm-mingw-20250430-ucrt-macos-universal/bin:$PATH"
113+
CC=aarch64-linux-musl-gcc GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.arm64.linux.so main.go
114+
CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.amd64.windows.dll main.go
115+
CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.386.windows.dll main.go
116+
CC=aarch64-w64-mingw32-gcc GOOS=windows GOARCH=arm64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.arm64.windows.dll main.go
117+
CC=gcc GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.arm64.darwin.dylib main.go
118+
CC=gcc GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -buildmode=c-shared -o libexcelize.amd64.darwin.dylib main.go
119+
rm -f libexcelize.*.h
120+
fi
121+
122+
- name: Upload Linux Artifacts
123+
if: matrix.os == 'ubuntu-24.04'
124+
uses: actions/upload-artifact@v4
113125
with:
114-
name: libexcelize
126+
name: linux-artifacts
115127
path: |
116128
libexcelize.386.linux.so
117129
libexcelize.amd64.linux.so
130+
131+
- name: Upload Darwin Artifacts
132+
if: matrix.os == 'macos-latest'
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: darwin-artifacts
136+
path: |
118137
libexcelize.arm64.linux.so
119138
libexcelize.amd64.windows.dll
120139
libexcelize.386.windows.dll

excelize.py

+115-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def load_lib() -> Optional[str]:
5555
"x86": "386",
5656
"i386": "386",
5757
"i686": "386",
58+
"amd64": "386",
5859
},
5960
},
6061
"darwin": {
@@ -74,6 +75,7 @@ def load_lib() -> Optional[str]:
7475
"x86": "386",
7576
"i386": "386",
7677
"i686": "386",
78+
"amd64": "386",
7779
},
7880
},
7981
}
@@ -88,7 +90,7 @@ def load_lib() -> Optional[str]:
8890

8991
lib = CDLL(os.path.join(os.path.dirname(__file__), load_lib()))
9092
ENCODE = "utf-8"
91-
__version__ = "0.0.3"
93+
__version__ = "0.0.4"
9294
uppercase_words = ["id", "rgb", "sq", "xml"]
9395

9496

@@ -781,7 +783,11 @@ def add_form_control(self, sheet: str, opts: FormControl) -> None:
781783
control options. Supported form control type: button, check box, group
782784
box, label, option button, scroll bar and spinner. If set macro for the
783785
form control, the workbook extension should be XLSM or XLTM. Scroll
784-
value must be between 0 and 30000.
786+
value must be between 0 and 30000. Please note that if a cell link is
787+
set for a checkbox form control, Excelize will not assign a value to the
788+
linked cell when the checkbox is checked. To reflect the checkbox state,
789+
please use the `set_cell_value` function to manually set the linked
790+
cell's value to true.
785791
786792
Args:
787793
sheet (str): The worksheet name
@@ -790,6 +796,112 @@ def add_form_control(self, sheet: str, opts: FormControl) -> None:
790796
Returns:
791797
None: Return None if no error occurred, otherwise raise a
792798
RuntimeError with the message.
799+
800+
Example:
801+
Example 1, add button form control with macro, rich-text, custom
802+
button size, print property on Sheet1!A2, and let the button do not
803+
move or size with cells:
804+
805+
```python
806+
try:
807+
f.add_form_control(
808+
"Sheet1",
809+
excelize.FormControl(
810+
cell="A2",
811+
type=excelize.FormControlType.FormControlButton,
812+
macro="Button1_Click",
813+
width=140,
814+
height=60,
815+
text="Button 1\r\n",
816+
paragraph=[
817+
excelize.RichTextRun(
818+
font=excelize.Font(
819+
bold=True,
820+
italic=True,
821+
underline="single",
822+
family="Times New Roman",
823+
size=14,
824+
color="777777",
825+
),
826+
text="C1=A1+B1",
827+
),
828+
],
829+
format=excelize.GraphicOptions(
830+
print_object=True,
831+
positioning="absolute",
832+
),
833+
),
834+
)
835+
except RuntimeError as err:
836+
print(err)
837+
```
838+
839+
Example 2, add option button form control with checked status and
840+
text on Sheet1!A1:
841+
842+
```python
843+
try:
844+
f.add_form_control(
845+
"Sheet1",
846+
excelize.FormControl(
847+
cell="A2",
848+
type=excelize.FormControlType.FormControlOptionButton,
849+
text="Option Button 1",
850+
checked=True,
851+
),
852+
)
853+
except RuntimeError as err:
854+
print(err)
855+
```
856+
857+
Example 3, add spin button form control on Sheet1!B1 to increase or
858+
decrease the value of Sheet1!A1:
859+
860+
```python
861+
try:
862+
f.add_form_control(
863+
"Sheet1",
864+
excelize.FormControl(
865+
cell="B1",
866+
type=excelize.FormControlType.FormControlSpinButton,
867+
width=15,
868+
height=40,
869+
current_val=7,
870+
min_val=5,
871+
max_val=10,
872+
inc_change=1,
873+
cell_link="A1",
874+
),
875+
)
876+
except RuntimeError as err:
877+
print(err)
878+
```
879+
880+
Example 4, add horizontally scroll bar form control on Sheet1!A2 to
881+
change the value of Sheet1!A1 by click the scroll arrows or drag
882+
the scroll box:
883+
884+
```python
885+
try:
886+
f.add_form_control(
887+
"Sheet1",
888+
excelize.FormControl(
889+
cell="A2",
890+
type=excelize.FormControlType.FormControlScrollBar,
891+
width=140,
892+
height=20,
893+
current_val=50,
894+
min_val=10,
895+
max_val=100,
896+
inc_change=1,
897+
page_change=1,
898+
cell_link="A1",
899+
horizontally=True,
900+
),
901+
)
902+
except RuntimeError as err:
903+
print(err)
904+
```
793905
"""
794906
lib.AddFormControl.restype = c_char_p
795907
options = py_value_to_c(opts, types_go._FormControl())
@@ -842,7 +954,7 @@ def add_picture_from_bytes(self, sheet: str, cell: str, picture: Picture) -> Non
842954
JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ. Note that this function
843955
only supports adding pictures placed over the cells currently, and
844956
doesn't support adding pictures placed in cells or creating the Kingsoft
845-
WPS Office embedded image cells
957+
WPS Office embedded image cells.
846958
847959
Args:
848960
sheet (str): The worksheet name

go.mod

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
module github.com/xuri/excelize-py
22

3-
go 1.20
3+
go 1.23.0
44

55
require (
66
github.com/xuri/excelize/v2 v2.9.1-0.20250219061259-52642854413f
7-
golang.org/x/image v0.24.0
7+
golang.org/x/image v0.26.0
88
)
99

1010
require (
1111
github.com/richardlehane/mscfb v1.0.4 // indirect
1212
github.com/richardlehane/msoleps v1.0.4 // indirect
13-
github.com/tiendc/go-deepcopy v1.5.0 // indirect
14-
github.com/xuri/efp v0.0.0-20241211021726-c4e992084aa6 // indirect
15-
github.com/xuri/nfp v0.0.0-20250111060730-82a408b9aa71 // indirect
16-
golang.org/x/crypto v0.33.0 // indirect
17-
golang.org/x/net v0.35.0 // indirect
18-
golang.org/x/text v0.22.0 // indirect
13+
github.com/tiendc/go-deepcopy v1.5.3 // indirect
14+
github.com/xuri/efp v0.0.0-20250227110027-3491fafc2b79 // indirect
15+
github.com/xuri/nfp v0.0.0-20250226145837-86d5fc24b2ba // indirect
16+
golang.org/x/crypto v0.37.0 // indirect
17+
golang.org/x/net v0.39.0 // indirect
18+
golang.org/x/text v0.24.0 // indirect
1919
)

go.sum

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
23
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
35
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
46
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
57
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
68
github.com/richardlehane/msoleps v1.0.4 h1:WuESlvhX3gH2IHcd8UqyCuFY5yiq/GR/yqaSM/9/g00=
79
github.com/richardlehane/msoleps v1.0.4/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
810
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
9-
github.com/tiendc/go-deepcopy v1.5.0 h1:TbtS9hclrKZcF1AHby8evDm4mIQU36i6tSYuvx/TstY=
10-
github.com/tiendc/go-deepcopy v1.5.0/go.mod h1:toXoeQoUqXOOS/X4sKuiAoSk6elIdqc0pN7MTgOOo2I=
11-
github.com/xuri/efp v0.0.0-20241211021726-c4e992084aa6 h1:8m6DWBG+dlFNbx5ynvrE7NgI+Y7OlZVMVTpayoW+rCc=
12-
github.com/xuri/efp v0.0.0-20241211021726-c4e992084aa6/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
11+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
12+
github.com/tiendc/go-deepcopy v1.5.3 h1:WzBAx2nO+8NLD5AXHFhUQ3meZckatMhN8rReQJnuBy8=
13+
github.com/tiendc/go-deepcopy v1.5.3/go.mod h1:toXoeQoUqXOOS/X4sKuiAoSk6elIdqc0pN7MTgOOo2I=
14+
github.com/xuri/efp v0.0.0-20250227110027-3491fafc2b79 h1:78nKszZqigiBRBVcoe/AuPzyLTWW5B+ltBaUX1rlIXA=
15+
github.com/xuri/efp v0.0.0-20250227110027-3491fafc2b79/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
1316
github.com/xuri/excelize/v2 v2.9.1-0.20250219061259-52642854413f h1:6r2z3li0dWKGsis3HqEsZnEb/FKq/AE88eBwV4zMkog=
1417
github.com/xuri/excelize/v2 v2.9.1-0.20250219061259-52642854413f/go.mod h1:pLb4VqhRJ56LzWGi1Oa30+VQ4Jbmn8kbPLfiwAvBuCA=
15-
github.com/xuri/nfp v0.0.0-20250111060730-82a408b9aa71 h1:hOh7aVDrvGJRxzXrQbDY8E+02oaI//5cHL+97oYpEPw=
16-
github.com/xuri/nfp v0.0.0-20250111060730-82a408b9aa71/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
17-
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
18-
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
19-
golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
20-
golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8=
21-
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
22-
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
23-
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
24-
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
18+
github.com/xuri/nfp v0.0.0-20250226145837-86d5fc24b2ba h1:DhIu6n3qU0joqG9f4IO6a/Gkerd+flXrmlJ+0yX2W8U=
19+
github.com/xuri/nfp v0.0.0-20250226145837-86d5fc24b2ba/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
20+
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
21+
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
22+
golang.org/x/image v0.26.0 h1:4XjIFEZWQmCZi6Wv8BoxsDhRU3RVnLX04dToTDAEPlY=
23+
golang.org/x/image v0.26.0/go.mod h1:lcxbMFAovzpnJxzXS3nyL83K27tmqtKzIJpctK8YO5c=
24+
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=
25+
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
26+
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
27+
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
2528
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
29+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

types_c.h

+2
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ struct ChartPlotArea
422422
int SecondPlotValues;
423423
bool ShowBubbleSize;
424424
bool ShowCatName;
425+
bool ShowDataTable;
426+
bool ShowDataTableKeys;
425427
bool ShowLeaderLines;
426428
bool ShowPercent;
427429
bool ShowSerName;

types_go.py

+2
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ class _ChartPlotArea(Structure):
396396
("SecondPlotValues", c_int),
397397
("ShowBubbleSize", c_bool),
398398
("ShowCatName", c_bool),
399+
("ShowDataTable", c_bool),
400+
("ShowDataTableKeys", c_bool),
399401
("ShowLeaderLines", c_bool),
400402
("ShowPercent", c_bool),
401403
("ShowSerName", c_bool),

types_py.py

+2
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ class ChartPlotArea:
524524
second_plot_values: int = 0
525525
show_bubble_size: bool = False
526526
show_cat_name: bool = False
527+
show_data_table: bool = False
528+
show_data_table_keys: bool = False
527529
show_leader_lines: bool = False
528530
show_percent: bool = False
529531
show_ser_name: bool = False

0 commit comments

Comments
 (0)