@@ -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
8991lib = CDLL (os .path .join (os .path .dirname (__file__ ), load_lib ()))
9092ENCODE = "utf-8"
91- __version__ = "0.0.3 "
93+ __version__ = "0.0.4 "
9294uppercase_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
0 commit comments