@@ -2716,7 +2716,7 @@ def get_active_sheet_index(self) -> int:
27162716 Returns:
27172717 int: The active sheet index
27182718 """
2719- lib .GetActiveSheetIndex .restype = c_int
2719+ lib .GetActiveSheetIndex .restype = c_longlong
27202720 res = lib .GetActiveSheetIndex (self .file_index )
27212721 return res
27222722
@@ -6134,6 +6134,27 @@ def coordinates_to_cell_name(col: int, row: int, *is_absolute: bool) -> str:
61346134 raise RuntimeError (err )
61356135
61366136
6137+ def join_cell_name (col : str , row : int ) -> str :
6138+ """
6139+ Joins cell name from column name and row number.
6140+
6141+ Args:
6142+ col (str): The column name
6143+ row (int): The row number
6144+
6145+ Returns:
6146+ str: Return a cell name if no error occurred, otherwise raise a
6147+ RuntimeError with the message.
6148+ """
6149+ prepare_args ([col , row ], [argsRule ("col" , [str ]), argsRule ("row" , [int ])])
6150+ lib .JoinCellName .restype = types_go ._StringErrorResult
6151+ res = lib .JoinCellName (col .encode (ENCODE ), c_longlong (row ))
6152+ err = res .err .decode (ENCODE )
6153+ if not err :
6154+ return res .val .decode (ENCODE )
6155+ raise RuntimeError (err )
6156+
6157+
61376158def new_file () -> File :
61386159 """
61396160 Create new file by default template.
@@ -6201,3 +6222,36 @@ def open_reader(buffer: bytes, *opts: Options) -> Optional[File]:
62016222 if err == "" :
62026223 return File (res .val )
62036224 raise RuntimeError (err )
6225+
6226+
6227+ def split_cell_name (cell : str ) -> Tuple [str , int ]:
6228+ """
6229+ Splits cell name to column name and row number.
6230+
6231+ Args:
6232+ cell (str): The cell reference
6233+
6234+ Returns:
6235+ Tuple[str, int]: Return a tuple containing column name and row number if
6236+ no error occurred, otherwise raise a RuntimeError with the message.
6237+
6238+ Example:
6239+ For example:
6240+
6241+ ```python
6242+ try:
6243+ col, row = excelize.split_cell_name("AK74") # return "AK", 74
6244+ except (RuntimeError, TypeError) as err:
6245+ print(err)
6246+ ```
6247+ """
6248+ prepare_args ([cell ], [argsRule ("cell" , [str ])])
6249+ lib .SplitCellName .restype = types_go ._StringIntErrorResult
6250+ res = lib .SplitCellName (cell .encode (ENCODE ))
6251+ err = res .err .decode (ENCODE )
6252+ if not err :
6253+ return (
6254+ res .strVal .decode (ENCODE ),
6255+ res .intVal ,
6256+ )
6257+ raise RuntimeError (err )
0 commit comments