def test_merge(self): ws = Worksheet(self.wb) string_table = {'':'', 'Cell A1':'Cell A1','Cell B1':'Cell B1'} ws.cell('A1').value = 'Cell A1' ws.cell('B1').value = 'Cell B1' xml_string = write_worksheet(ws, string_table, None) assert '<c r="B1" t="s"><v>Cell B1</v></c>' in xml_string ws.merge_cells('A1:B1') xml_string = write_worksheet(ws, string_table, None) assert '<c r="B1" t="s"><v>Cell B1</v></c>' not in xml_string assert '<mergeCells><mergeCell ref="A1:B1"></mergeCell></mergeCells>' in xml_string ws.unmerge_cells('A1:B1') xml_string = write_worksheet(ws, string_table, None) assert '<mergeCell ref="A1:B1"></mergeCell>' not in xml_string
def test_merge(self): ws = Worksheet(self.wb) string_table = {'': '', 'Cell A1': 'Cell A1', 'Cell B1': 'Cell B1'} ws.cell('A1').value = 'Cell A1' ws.cell('B1').value = 'Cell B1' xml_string = write_worksheet(ws, string_table, None) assert '<v>Cell B1</v>' in xml_string ws.merge_cells('A1:B1') xml_string = write_worksheet(ws, string_table, None) assert '<v>Cell B1</v>' not in xml_string assert '<mergeCells count="1"><mergeCell ref="A1:B1"></mergeCell></mergeCells>' in xml_string ws.unmerge_cells('A1:B1') xml_string = write_worksheet(ws, string_table, None) assert '<mergeCell ref="A1:B1"/>' not in xml_string
def test_unmerge_coordinate(self): ws = Worksheet(self.wb) ws._merged_cells = ["A1:D4"] ws.unmerge_cells(start_row=1, start_column=1, end_row=4, end_column=4)
def test_unmerge_range_string(self): ws = Worksheet(self.wb) ws._merged_cells = ["A1:D4"] ws.unmerge_cells("A1:D4")
def test_merge(self): ws = Worksheet(self.wb) string_table = {'':'', 'Cell A1':'Cell A1', 'Cell B1':'Cell B1'} expected = """ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <sheetPr> <outlinePr summaryRight="1" summaryBelow="1"/> </sheetPr> <dimension ref="A1:B1"/> <sheetViews> <sheetView workbookViewId="0"> <selection sqref="A1" activeCell="A1"/> </sheetView> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <cols> <col min="1" max="1" width="9.10"/> <col min="2" max="2" width="9.10"/> </cols> <sheetData> <row r="1" spans="1:2"> <c r="A1" t="s"> <v>Cell A1</v> </c> <c r="B1" t="s"> <v>Cell B1</v> </c> </row> </sheetData> </worksheet> """ ws.cell('A1').value = 'Cell A1' ws.cell('B1').value = 'Cell B1' xml = write_worksheet(ws, string_table, None) diff = compare_xml(xml, expected) assert diff is None, diff ws.merge_cells('A1:B1') xml = write_worksheet(ws, string_table, None) expected = """ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <sheetPr> <outlinePr summaryRight="1" summaryBelow="1"/> </sheetPr> <dimension ref="A1:B1"/> <sheetViews> <sheetView workbookViewId="0"> <selection sqref="A1" activeCell="A1"/> </sheetView> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <cols> <col min="1" max="1" width="9.10"/> <col min="2" max="2" width="9.10"/> </cols> <sheetData> <row r="1" spans="1:2"> <c r="A1" t="s"> <v>Cell A1</v> </c> <c r="B1" t="s"/> </row> </sheetData> <mergeCells count="1"> <mergeCell ref="A1:B1"/> </mergeCells> </worksheet> """ diff = compare_xml(xml, expected) assert diff is None, diff ws.unmerge_cells('A1:B1') xml = write_worksheet(ws, string_table, None) expected = """ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <sheetPr> <outlinePr summaryRight="1" summaryBelow="1"/> </sheetPr> <dimension ref="A1:B1"/> <sheetViews> <sheetView workbookViewId="0"> <selection sqref="A1" activeCell="A1"/> </sheetView> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <cols> <col min="1" max="1" width="9.10"/> <col min="2" max="2" width="9.10"/> </cols> <sheetData> <row r="1" spans="1:2"> <c r="A1" t="s"> <v>Cell A1</v> </c> <c r="B1" t="s"/> </row> </sheetData> </worksheet> """ diff = compare_xml(xml, expected) assert diff is None, diff
def test_merge(self): ws = Worksheet(self.wb) string_table = ['Cell A1', 'Cell B1'] expected = """ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <sheetPr> <outlinePr summaryRight="1" summaryBelow="1"/> </sheetPr> <dimension ref="A1:B1"/> <sheetViews> <sheetView workbookViewId="0"> <selection sqref="A1" activeCell="A1"/> </sheetView> </sheetViews> <sheetFormatPr baseColWidth="10" defaultRowHeight="15"/> <sheetData> <row r="1" spans="1:2"> <c r="A1" t="s"> <v>0</v> </c> <c r="B1" t="s"> <v>1</v> </c> </row> </sheetData> <pageMargins left="0.75" right="0.75" top="1" bottom="1" header="0.5" footer="0.5"/> </worksheet> """ ws.cell('A1').value = 'Cell A1' ws.cell('B1').value = 'Cell B1' xml = write_worksheet(ws, string_table, None) diff = compare_xml(xml, expected) assert diff is None, diff ws.merge_cells('A1:B1') xml = write_worksheet(ws, string_table, None) expected = """ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <sheetPr> <outlinePr summaryRight="1" summaryBelow="1"/> </sheetPr> <dimension ref="A1:B1"/> <sheetViews> <sheetView workbookViewId="0"> <selection sqref="A1" activeCell="A1"/> </sheetView> </sheetViews> <sheetFormatPr baseColWidth="10" defaultRowHeight="15"/> <sheetData> <row r="1" spans="1:2"> <c r="A1" t="s"> <v>0</v> </c> <c r="B1" t="s"/> </row> </sheetData> <mergeCells count="1"> <mergeCell ref="A1:B1"/> </mergeCells> <pageMargins left="0.75" right="0.75" top="1" bottom="1" header="0.5" footer="0.5"/> </worksheet> """ diff = compare_xml(xml, expected) assert diff is None, diff ws.unmerge_cells('A1:B1') xml = write_worksheet(ws, string_table, None) expected = """ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <sheetPr> <outlinePr summaryRight="1" summaryBelow="1"/> </sheetPr> <dimension ref="A1:B1"/> <sheetViews> <sheetView workbookViewId="0"> <selection sqref="A1" activeCell="A1"/> </sheetView> </sheetViews> <sheetFormatPr baseColWidth="10" defaultRowHeight="15"/> <sheetData> <row r="1" spans="1:2"> <c r="A1" t="s"> <v>0</v> </c> <c r="B1" t="s"/> </row> </sheetData> <pageMargins left="0.75" right="0.75" top="1" bottom="1" header="0.5" footer="0.5"/> </worksheet> """ diff = compare_xml(xml, expected) assert diff is None, diff
def test_merge(self): ws = Worksheet(self.wb) string_table = {'': '', 'Cell A1': 'Cell A1', 'Cell B1': 'Cell B1'} expected = """ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <sheetPr> <outlinePr summaryRight="1" summaryBelow="1"/> </sheetPr> <dimension ref="A1:B1"/> <sheetViews> <sheetView workbookViewId="0"> <selection sqref="A1" activeCell="A1"/> </sheetView> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <cols> <col min="1" max="1" width="9.10"/> <col min="2" max="2" width="9.10"/> </cols> <sheetData> <row r="1" spans="1:2"> <c r="A1" t="s"> <v>Cell A1</v> </c> <c r="B1" t="s"> <v>Cell B1</v> </c> </row> </sheetData> </worksheet> """ ws.cell('A1').value = 'Cell A1' ws.cell('B1').value = 'Cell B1' xml = write_worksheet(ws, string_table, None) diff = compare_xml(xml, expected) assert diff is None, diff ws.merge_cells('A1:B1') xml = write_worksheet(ws, string_table, None) expected = """ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <sheetPr> <outlinePr summaryRight="1" summaryBelow="1"/> </sheetPr> <dimension ref="A1:B1"/> <sheetViews> <sheetView workbookViewId="0"> <selection sqref="A1" activeCell="A1"/> </sheetView> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <cols> <col min="1" max="1" width="9.10"/> <col min="2" max="2" width="9.10"/> </cols> <sheetData> <row r="1" spans="1:2"> <c r="A1" t="s"> <v>Cell A1</v> </c> <c r="B1" t="s"/> </row> </sheetData> <mergeCells count="1"> <mergeCell ref="A1:B1"/> </mergeCells> </worksheet> """ diff = compare_xml(xml, expected) assert diff is None, diff ws.unmerge_cells('A1:B1') xml = write_worksheet(ws, string_table, None) expected = """ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <sheetPr> <outlinePr summaryRight="1" summaryBelow="1"/> </sheetPr> <dimension ref="A1:B1"/> <sheetViews> <sheetView workbookViewId="0"> <selection sqref="A1" activeCell="A1"/> </sheetView> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <cols> <col min="1" max="1" width="9.10"/> <col min="2" max="2" width="9.10"/> </cols> <sheetData> <row r="1" spans="1:2"> <c r="A1" t="s"> <v>Cell A1</v> </c> <c r="B1" t="s"/> </row> </sheetData> </worksheet> """ diff = compare_xml(xml, expected) assert diff is None, diff