@@ -1756,6 +1756,22 @@ def get_tables(self, sheet: str) -> Tuple[List[Table], Optional[Exception]]:
17561756 err = res .Err .decode (ENCODE )
17571757 return tables if tables else [], None if err == "" else Exception (err )
17581758
1759+ def get_workbook_props (self ) -> Tuple [WorkbookPropsOptions , Optional [Exception ]]:
1760+ """
1761+ Get all tables in a worksheet by given worksheet name.
1762+
1763+ Returns:
1764+ Tuple[List[WorkbookPropsOptions], Optional[Exception]]: A tuple
1765+ containing the workbook property options and an exception if an
1766+ error occurred, otherwise None.
1767+ """
1768+ lib .GetWorkbookProps .restype = types_go ._GetWorkbookPropsResult
1769+ res = lib .GetWorkbookProps (self .file_index )
1770+ err = res .err .decode (ENCODE )
1771+ return c_value_to_py (res .opts , WorkbookPropsOptions ()) if err == "" else None , (
1772+ None if err == "" else Exception (err )
1773+ )
1774+
17591775 def insert_cols (self , sheet : str , col : str , n : int ) -> Optional [Exception ]:
17601776 """
17611777 Insert new columns before the given column name and number of columns.
@@ -1789,6 +1805,39 @@ def insert_cols(self, sheet: str, col: str, n: int) -> Optional[Exception]:
17891805 ).decode (ENCODE )
17901806 return None if err == "" else Exception (err )
17911807
1808+ def insert_rows (self , sheet : str , row : int , n : int ) -> Optional [Exception ]:
1809+ """
1810+ Insert new rows after the given Excel row number starting from 1 and
1811+ number of rows. Use this method with caution, which will affect changes
1812+ in references such as formulas, charts, and so on. If there is any
1813+ referenced value of the worksheet, it will cause a file error when you
1814+ open it. The excelize only partially updates these references currently.
1815+
1816+ Args:
1817+ sheet (str): The worksheet name
1818+ row (int): The row number
1819+ n (int): The rows
1820+
1821+ Returns:
1822+ Optional[Exception]: Returns None if no error occurred,
1823+ otherwise returns an Exception with the message.
1824+
1825+ Example:
1826+ For example, create two rows before row 3 in Sheet1:
1827+
1828+ .. code-block:: python
1829+
1830+ err = f.insert_rows("Sheet1", 3, 2)
1831+ """
1832+ lib .InsertRows .restype = c_char_p
1833+ err = lib .InsertRows (
1834+ self .file_index ,
1835+ sheet .encode (ENCODE ),
1836+ c_int (row ),
1837+ c_int (n ),
1838+ ).decode (ENCODE )
1839+ return None if err == "" else Exception (err )
1840+
17921841 def merge_cell (
17931842 self , sheet : str , top_left_cell : str , bottom_right_cell : str
17941843 ) -> Optional [Exception ]:
@@ -3273,7 +3322,7 @@ def set_workbook_props(self, opts: WorkbookPropsOptions) -> Optional[Exception]:
32733322 Sets workbook properties.
32743323
32753324 Args:
3276- opts (WorkbookPropsOptions): TThe workbook property options
3325+ opts (WorkbookPropsOptions): The workbook property options
32773326
32783327 Returns:
32793328 Optional[Exception]: Returns None if no error occurred,
0 commit comments