Beispiel #1
0
    # 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 ...',
    docx.replace('the awesomeness', 'the goshdarned awesomeness')
    print 'done.'

    # Add a pagebreak
    docx.pagebreak(type='page', orient='portrait')

    docx.heading('Ideas? Questions? Want to contribute?', 2)
    docx.paragraph('Email <*****@*****.**>')

    docx.coreproperties(title='Python docx demo',
                        subject='A practical example of making docx from Python',
                        creator='Mike MacCana',
                        keywords= ['python', 'Office Open XML', 'Word'])

    # Save our document
    docx.savedocx('Welcome to the Python docx module.docx')