def test_write_comments(worksheet, write_worksheet): ws = worksheet worksheet._comments = True xml = write_worksheet(ws) expected = """ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <sheetPr> <outlinePr summaryBelow="1" summaryRight="1"/> <pageSetUpPr/> </sheetPr> <dimension ref="A1:A1"/> <sheetViews> <sheetView workbookViewId="0"> <selection activeCell="A1" sqref="A1"/> </sheetView> </sheetViews> <sheetFormatPr baseColWidth="8" defaultRowHeight="15"/> <sheetData/> <pageMargins bottom="1" footer="0.5" header="0.5" left="0.75" right="0.75" top="1"/> <legacyDrawing r:id="anysvml"></legacyDrawing> </worksheet> """ diff = compare_xml(xml, expected) assert diff is None, diff
def _write(self): from openpyxl25.drawing.spreadsheet_drawing import SpreadsheetDrawing from openpyxl25.writer.worksheet import write_worksheet self._drawing = SpreadsheetDrawing() self._drawing.charts = self._charts self._drawing.images = self._images return write_worksheet(self)
def test_vba_comments(datadir, write_worksheet): datadir.chdir() fname = 'vba+comments.xlsm' wb = load_workbook(fname, keep_vba=True) ws = wb['Form Controls'] sheet = fromstring(write_worksheet(ws)) els = sheet.findall('{%s}legacyDrawing' % SHEET_MAIN_NS) assert len( els) == 1, "Wrong number of legacyDrawing elements %d" % len(els) assert els[0].get('{%s}id' % REL_NS) == 'anysvml'
def test_write_tables(worksheet, write_worksheet): from openpyxl25.worksheet.table import Table worksheet.append(list(u"ABCDEF\xfc")) worksheet._tables = [Table(displayName="Table1", ref="A1:G6")] xml = write_worksheet(worksheet) assert len(worksheet._rels) == 1 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"/> <pageSetUpPr/> </sheetPr> <dimension ref="A1:G1"/> <sheetViews> <sheetView workbookViewId="0"> <selection sqref="A1" activeCell="A1"/> </sheetView> </sheetViews> <sheetFormatPr baseColWidth="8" defaultRowHeight="15"/> <sheetData> <row r="1" spans="1:7"> <c r="A1" t="s"> <v>0</v> </c> <c r="B1" t="s"> <v>1</v> </c> <c r="C1" t="s"> <v>2</v> </c> <c r="D1" t="s"> <v>3</v> </c> <c r="E1" t="s"> <v>4</v> </c> <c r="F1" t="s"> <v>5</v> </c> <c r="G1" t="s"> <v>6</v> </c> </row> </sheetData> <pageMargins left="0.75" right="0.75" top="1" bottom="1" header="0.5" footer="0.5"/> <tableParts count="1"> <tablePart r:id="rId1" /> </tableParts> </worksheet> """ diff = compare_xml(xml, expected) assert diff is None, diff