
    Mwg	                     0    d dl m Z  ddlmZ  G d d      Zy)    )copy   )	Worksheetc                   .    e Zd ZdZd Zd Zd Zd Zd Zy)WorksheetCopyz
    Copy the values, styles, dimensions, merged cells, margins, and
    print/page setup from one worksheet to another within the same
    workbook.
    c                 @    || _         || _        | j                          y N)sourcetarget_verify_resources)selfsource_worksheettarget_worksheets      P/var/www/horilla/myenv/lib/python3.12/site-packages/openpyxl/worksheet/copier.py__init__zWorksheetCopy.__init__   s    &&     c                 8   t        | j                  t              s%t        | j                  t              st	        d      | j                  | j                  u rt        d      | j                  j                  | j                  j                  k7  rt        d      y )NzCan only copy worksheetsz!Cannot copy a worksheet to itselfz7Cannot copy between worksheets from different workbooks)
isinstancer
   r   r   	TypeError
ValueErrorparentr   s    r   r   zWorksheetCopy._verify_resources   ss    4;;	2t{{I6677;;$++%@AA;;!3!33VWW 4r   c                 l   | j                          | j                          t        | j                  j                        | j
                  _        t        | j                  j                        | j
                  _        t        | j                  j                        | j
                  _        t        | j                  j                        | j
                  _        t        | j                  j                        | j
                  _	        t        | j                  j                        | j
                  _
        y r	   )_copy_cells_copy_dimensionsr   r
   sheet_formatr   sheet_propertiesmerged_cellspage_margins
page_setupprint_optionsr   s    r   copy_worksheetzWorksheetCopy.copy_worksheet#   s    #'(@(@#A '+DKK,H,H'I$#'(@(@#A #'(@(@#A !%dkk&<&<!=$()B)B$C!r   c                    | j                   j                  j                         D ]  \  \  }}}| j                  j	                  ||      }|j
                  |_        |j                  |_        |j                  rt        |j                        |_	        |j                  rt        |j                        |_        |j                  st        |j                        |_         y )N)columnrow)r
   _cellsitemsr   cell_value	data_type	has_styler   _style	hyperlink
_hyperlinkcomment)r   r%   colsource_celltarget_cells        r   r   zWorksheetCopy._copy_cells/   s    (,(:(:(@(@(B 	@#JS#++**#3*?K!,!3!3K$/$9$9K!$$%)+*<*<%="$$)-k.C.C)D&""&*;+>+>&?#	@r   c                     dD ]h  }t        | j                  |      }t        | j                  |      }|j                         D ]'  \  }}t	        |      ||<   | j                  ||   _        ) j y )N)row_dimensionscolumn_dimensions)getattrr
   r   r'   r   	worksheet)r   attrsrcr   keydims         r   r   zWorksheetCopy._copy_dimensions@   sg    ; 	4D$++t,CT[[$/FIIK 4S"3is(,s%4	4r   N)	__name__
__module____qualname____doc__r   r   r"   r   r    r   r   r   r   	   s#    !
X	D@"4r   r   N)r   r7   r   r   r@   r   r   <module>rA      s      =4 =4r   