@@ -179,7 +179,6 @@ def c_value_to_py(ctypes_instance, py_instance):
179179 if value :
180180 if any (is_py_primitive_type (arg ) for arg in py_field_args ):
181181 # Pointer of the Go basic data type, for example: *string
182- value = getattr (ctypes_instance , c_field_name )
183182 setattr (
184183 py_instance ,
185184 py_field_name ,
@@ -1482,6 +1481,29 @@ def get_cell_style(self, sheet: str, cell: str) -> Tuple[int, Optional[Exception
14821481 err = res .err .decode (ENCODE )
14831482 return res .val , None if err == "" else Exception (err )
14841483
1484+ def get_cell_rich_text (
1485+ self , sheet : str , cell : str
1486+ ) -> Tuple [List [RichTextRun ], Optional [Exception ]]:
1487+ """
1488+ Get rich text of cell by given worksheet and cell reference.
1489+
1490+ Args:
1491+ sheet (str): The worksheet name
1492+ cell (str): The cell reference
1493+
1494+ Returns:
1495+ Tuple[List[RichTextRun], Optional[Exception]]: A tuple containing
1496+ the rich text runs and an exception if an error occurred, otherwise
1497+ None.
1498+ """
1499+ lib .GetCellRichText .restype = types_go ._GetCellRichTextResult
1500+ res = lib .GetCellRichText (
1501+ self .file_index , sheet .encode (ENCODE ), cell .encode (ENCODE )
1502+ )
1503+ runs = c_value_to_py (res , GetCellRichTextResult ()).runs
1504+ err = res .Err .decode (ENCODE )
1505+ return runs if runs else [], None if err == "" else Exception (err )
1506+
14851507 def get_cell_value (
14861508 self , sheet : str , cell : str , * opts : Options
14871509 ) -> Tuple [str , Optional [Exception ]]:
@@ -1703,7 +1725,7 @@ def get_tables(self, sheet: str) -> Tuple[List[Table], Optional[Exception]]:
17031725 res = lib .GetTables (self .file_index , sheet .encode (ENCODE ))
17041726 tables = c_value_to_py (res , GetTablesResult ()).tables
17051727 err = res .Err .decode (ENCODE )
1706- return tables , None if err == "" else Exception (err )
1728+ return tables if tables else [] , None if err == "" else Exception (err )
17071729
17081730 def insert_cols (self , sheet : str , col : str , n : int ) -> Optional [Exception ]:
17091731 """
@@ -2119,8 +2141,8 @@ def set_active_sheet(self, index: int) -> Optional[Exception]:
21192141
21202142 def set_cell_bool (self , sheet : str , cell : str , value : bool ) -> Optional [Exception ]:
21212143 """
2122- Set bool type value of a cell by given worksheet name, cell reference and
2123- cell value.
2144+ Set bool type value of a cell by given worksheet name, cell reference
2145+ and cell value.
21242146
21252147 Args:
21262148 sheet (str): The worksheet name
@@ -2717,6 +2739,46 @@ def set_defined_name(self, defined_name: DefinedName) -> Optional[Exception]:
27172739 err = lib .SetDefinedName (self .file_index , byref (options )).decode (ENCODE )
27182740 return None if err == "" else Exception (err )
27192741
2742+ def set_doc_props (self , doc_properties : DocProperties ) -> Optional [Exception ]:
2743+ """
2744+ Set document core properties.
2745+
2746+ Args:
2747+ doc_properties (DocProperties): The doc properties
2748+
2749+ Returns:
2750+ Optional[Exception]: Returns None if no error occurred,
2751+ otherwise returns an Exception with the message.
2752+
2753+ Example:
2754+ For example:
2755+
2756+ .. code-block:: python
2757+
2758+ err = f.set_doc_props(
2759+ excelize.DocProperties(
2760+ category="category",
2761+ content_status="Draft",
2762+ created="2019-06-04T22:00:10Z",
2763+ creator="Go Excelize",
2764+ description="This file created by Go Excelize",
2765+ identifier="xlsx",
2766+ keywords="Spreadsheet",
2767+ last_modified_by="Go Author",
2768+ modified="2019-06-04T22:00:10Z",
2769+ revision="0",
2770+ subject="Test Subject",
2771+ title="Test Title",
2772+ language="en-US",
2773+ version="1.0.0",
2774+ )
2775+ )
2776+ """
2777+ lib .SetDocProps .restype = c_char_p
2778+ options = py_value_to_c (doc_properties , types_go ._DocProperties ())
2779+ err = lib .SetDocProps (self .file_index , byref (options )).decode (ENCODE )
2780+ return None if err == "" else Exception (err )
2781+
27202782 def set_header_footer (
27212783 self , sheet : str , opts : HeaderFooterOptions
27222784 ) -> Optional [Exception ]:
0 commit comments