U o^3 @stddlmZddlmZmZddlmZddlmZddl m Z Gddde Z Gd d d eZ Gd d d e Z d S)) Serialisable)IntegerSequence) MergedCell)Border) CellRangecs4eZdZdZejZdZdfdd ZddZ Z S) MergeCell mergeCell)refNcstt||dSN)superr __init__)selfr  __class__r/private/var/folders/sd/whlwsn6x1_qgglc0mjv25_695qk2gl/T/pip-install-4zq3fp6i/openpyxl/openpyxl/worksheet/merge.pyrszMergeCell.__init__cCs ||jSr )rr rrrr__copy__szMergeCell.__copy__)N) __name__ __module__ __qualname__tagnamercoordr __attrs__rr __classcell__rrrrr s r c@sBeZdZdZeddZeedZdZ dZ d d d Z e d d ZdS) MergeCellsZ mergeCellsT) allow_none)Z expected_typer )countNrcCs ||_dSr r)rr r rrrr+szMergeCells.__init__cCs t|jSr )lenr rrrrr 2szMergeCells.count)Nr) rrrrrr rr r Z __elements__rrpropertyrrrrr!s   rcs0eZdZdZfddZddZddZZS)MergedCellRangea MergedCellRange stores the border information of a merged cell in the top left cell of the merged cell. The remaining cells in the merged cell are stored as MergedCell objects and get their border information from the upper left cell. cs*||_tt|j|dd|_|dS)N)Z range_string)wsr r#r start_cell _get_borders)rZ worksheetrrrrr@szMergedCellRange.__init__cCsz|jj|j|jf|_|jdkr8|jj|j|jd|_|jj|j|jf}|dk rv|jj t |j j |j j d7_ dS)a If the upper left cell of the merged cell does not yet exist, it is created. The upper left cell gets the border information of the bottom and right border from the bottom right cell of the merged cell, if available. Nrowcolumn)rightbottom) r$_cellsgetZmin_rowZmin_colr%cellZmax_rowZmax_colborderrr*r+)rZend_cellrrrr&Gs  zMergedCellRange._get_bordersc Csddddg}|D]}t|jj|}tf||i}t||D]T}|jj|}|dkr|\}}t|j||d}||jj|j|j f<|j|7_q:qdS)a  Each cell of the merged cell is created as MergedCell if it does not already exist. The MergedCells at the edge of the merged cell gets its borders from the upper left cell. - The top MergedCells get the top border from the top left cell. - The bottom MergedCells get the bottom border from the top left cell. - The left MergedCells get the left border from the top left cell. - The right MergedCells get the right border from the top left cell. topleftr*r+Nr') getattrr%r/rr$r,r-rr(r)) rnamesnameZsider/rr.r(colrrrformat[s zMergedCellRange.format)rrr__doc__rr&r6rrrrrr#7s r#N)Z!openpyxl.descriptors.serialisablerZopenpyxl.descriptorsrrZopenpyxl.cell.cellrZopenpyxl.styles.bordersrZ cell_rangerr rr#rrrrs