@@ -84,7 +84,7 @@ def load_lib():
8484
8585lib = CDLL (os .path .join (os .path .dirname (__file__ ), load_lib ()))
8686ENCODE = "utf-8"
87- __version__ = "0.0.2 "
87+ __version__ = "0.0.3 "
8888uppercase_words = ["id" , "rgb" , "sq" , "xml" ]
8989
9090
@@ -474,6 +474,97 @@ def add_table(self, table: Table) -> Optional[Exception]:
474474 err = lib .StreamAddTable (self .sw_index , byref (options )).decode (ENCODE )
475475 return None if err == "" else Exception (err )
476476
477+ def insert_page_break (self , cell : str ) -> Optional [Exception ]:
478+ """
479+ Creates a page break to determine where the printed page ends and where
480+ begins the next one by a given cell reference, the content before the
481+ page break will be printed on one page and after the page break on
482+ another.
483+
484+ Args:
485+ cell (str): The cell reference
486+
487+ Returns:
488+ Optional[Exception]: Returns None if no error occurred,
489+ otherwise returns an Exception with the message.
490+ """
491+ lib .StreamInsertPageBreak .restype = c_char_p
492+ err = lib .StreamInsertPageBreak (self .sw_index , cell .encode (ENCODE )).decode (
493+ ENCODE
494+ )
495+ return None if err == "" else Exception (err )
496+
497+ def merge_cell (
498+ self , top_left_cell : str , bottom_right_cell : str
499+ ) -> Optional [Exception ]:
500+ """
501+ Merge cells by a given range reference for the stream writer. Don't
502+ create a merged cell that overlaps with another existing merged cell.
503+
504+ Args:
505+ top_left_cell (str): The top-left cell reference
506+ bottom_right_cell (str): The right-bottom cell reference
507+
508+ Returns:
509+ Optional[Exception]: Returns None if no error occurred,
510+ otherwise returns an Exception with the message.
511+ """
512+ lib .StreamMergeCell .restype = c_char_p
513+ err = lib .StreamMergeCell (
514+ self .sw_index ,
515+ top_left_cell .encode (ENCODE ),
516+ bottom_right_cell .encode (ENCODE ),
517+ ).decode (ENCODE )
518+ return None if err == "" else Exception (err )
519+
520+ def set_col_width (
521+ self , start_col : int , end_col : int , width : float
522+ ) -> Optional [Exception ]:
523+ """
524+ Set the width of a single column or multiple columns for the stream
525+ writer. Note that you must call the 'set_col_width' function before the
526+ 'set_row' function.
527+
528+ Args:
529+ start_col (int): The start column number
530+ end_col (int): The end column number
531+ width (float): The column width
532+
533+ Returns:
534+ Optional[Exception]: Returns None if no error occurred,
535+ otherwise returns an Exception with the message.
536+
537+ Example:
538+ For example set the width column B:C as 20:
539+
540+ .. code-block:: python
541+
542+ err = sw.set_col_width(2, 3, 20)
543+ """
544+ lib .StreamSetColWidth .restype = c_char_p
545+ err = lib .StreamSetColWidth (
546+ self .sw_index , c_int (start_col ), c_int (end_col ), c_double (width )
547+ ).decode (ENCODE )
548+ return None if err == "" else Exception (err )
549+
550+ def set_panes (self , opts : Panes ) -> Optional [Exception ]:
551+ """
552+ Create and remove freeze panes and split panes by giving panes options
553+ for the stream writer. Note that you must call the 'set_panes' function
554+ before the 'set_row' function.
555+
556+ Args:
557+ opts (Panes): The panes options
558+
559+ Returns:
560+ Optional[Exception]: Returns None if no error occurred,
561+ otherwise returns an Exception with the message.
562+ """
563+ lib .StreamSetPanes .restype = c_char_p
564+ options = py_value_to_c (opts , types_go ._Panes ())
565+ err = lib .StreamSetPanes (self .sw_index , byref (options )).decode (ENCODE )
566+ return None if err == "" else Exception (err )
567+
477568 def set_row (
478569 self ,
479570 cell : str ,
@@ -2477,7 +2568,7 @@ def set_col_width(
24772568 Args:
24782569 sheet (str): The worksheet name
24792570 start_col (str): The start column name
2480- end_col (bool ): The end column name
2571+ end_col (str ): The end column name
24812572 width (float): The column width
24822573
24832574 Returns:
0 commit comments