def simpledoc(): '''Make a docx (document, relationships) for use in other docx tests''' docx = Docx() docx.heading('Heading 1', 1) docx.heading('Heading 2', 2) docx.paragraph('Paragraph 1') for point in ['List Item 1', 'List Item 2', 'List Item 3']: docx.paragraph(point, style='ListNumber') docx.pagebreak(type='page') docx.paragraph('Paragraph 2') docx.table([['A1', 'A2', 'A3'], ['B1', 'B2', 'B3'], ['C1', 'C2', 'C3']]) docx.pagebreak(type='section', orient='portrait') docx.picture(IMAGE1_FILE, 'This is a test description') docx.pagebreak(type='section', orient='landscape') docx.paragraph('Paragraph 3') return docx
, ['C1', 'C2', 'C3'] ] docx.table(tbl_rows) docx.heading('Editing documents', 2) docx.paragraph('Thanks to the awesomeness of the lxml module, ' 'we can:') points = [ 'Search and replace' , 'Extract plain text of document' , 'Add and delete items anywhere within the document' ] for point in points: docx.paragraph(point, style='ListBullet') # Add an image docx.picture('image2.png', 'This is a test description') # Search and replace print 'Searching for something in a paragraph ...', if docx.search('the awesomeness'): print 'found it!' else: print 'nope.' print 'Searching for something in a heading ...', if docx.search('200 lines'): print 'found it!' else: print 'nope.' print 'Replacing ...',