Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions excelize.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,35 @@ def get_cell_value(
err = res.err.decode(ENCODE)
return res.val.decode(ENCODE), None if err == "" else Exception(err)

def get_col_outline_level(
self, sheet: str, col: str
) -> Tuple[int, Optional[Exception]]:
"""
Get outline level of a single column by given worksheet name and column
name.

Args:
sheet (str): The worksheet name
col (str): The column name

Returns:
Tuple[int, Optional[Exception]]: A tuple containing the column
outline level and an exception if an error occurred, otherwise None.

Example:
For example, get outline level of column D in Sheet1:

.. code-block:: python

level, err = f.get_col_outline_level("Sheet1", "D")
"""
lib.GetColOutlineLevel.restype = types_go._IntErrorResult
res = lib.GetColOutlineLevel(
self.file_index, sheet.encode(ENCODE), col.encode(ENCODE)
)
err = res.err.decode(ENCODE)
return res.val, None if err == "" else Exception(err)

def get_col_style(self, sheet: str, col: str) -> Tuple[int, Optional[Exception]]:
"""
Get column style ID by given worksheet name and column name.
Expand Down
16 changes: 16 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,22 @@ func GetCellValue(idx int, sheet, cell *C.char, opts *C.struct_Options) C.struct
return C.struct_StringErrorResult{val: C.CString(val), err: C.CString(emptyString)}
}

// GetColOutlineLevel provides a function to get outline level of a single
// column by given worksheet name and column name.
//
//export GetColOutlineLevel
func GetColOutlineLevel(idx int, sheet, col *C.char) C.struct_IntErrorResult {
f, ok := files.Load(idx)
if !ok {
return C.struct_IntErrorResult{val: C.int(0), err: C.CString(errFilePtr)}
}
val, err := f.(*excelize.File).GetColOutlineLevel(C.GoString(sheet), C.GoString(col))
if err != nil {
return C.struct_IntErrorResult{val: C.int(int32(val)), err: C.CString(err.Error())}
}
return C.struct_IntErrorResult{val: C.int(int32(val)), err: C.CString(emptyString)}
}

// GetColStyle provides a function to get column style ID by given worksheet
// name and column name. This function is concurrency safe.
//
Expand Down
3 changes: 3 additions & 0 deletions test_excelize.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ def test_style(self):
self.assertIsNone(err)

self.assertIsNone(f.set_col_outline_level("Sheet1", "D", 2))
level, err = f.get_col_outline_level("Sheet1", "D")
self.assertEqual(level, 2)
self.assertIsNone(err)
self.assertIsNone(f.set_row_outline("Sheet1", 2, 1))

self.assertIsNone(f.set_sheet_background("Sheet2", "chart.png"))
Expand Down