1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| from xml.dom.minidom import parse, parseString
import win32com.client as win32
def parseData():
document = """\
<client name="testn1">
test 1
</client>
"""
dom = parseString(document)
xmlTag = dom.getElementsByTagName('client')[0].toxml()
xmlData=xmlTag.replace('<client (...) >','').replace('</client>','')
print (xmlData)
def getText(nodelist):
rc = []
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc.append(node.data)
return ''.join(rc)
def rgb_to_hex(rgb):
strValue = '%02x%02x%02x' % rgb
iValue = int(strValue, 16)
return iValue
def word():
word = win32.gencache.EnsureDispatch('Word.Application')
worddoc = word.Documents.Add()
word.Visible = True
worddoc.PageSetup.Orientation = 1
worddoc.PageSetup.BookFoldPrinting = 1
worddoc.Content.Font.Size = 11
worddoc.Content.Paragraphs.TabStops.Add (100)
worddoc.Content.Text = "Hello, I am a text!"
location = worddoc.Range()
location.Collapse(1)
location.Paragraphs.Add()
location.Collapse(1)
table = location.Tables.Add (location, 2, 3)
table.ApplyStyleHeadingRows = 1
table.AutoFormat(16)
table.Cell(1,1).Range.InsertAfter("affaire")
table.Cell(1,2).Range.InsertAfter("Date d'échéance")
table.Cell(1,3).Range.InsertAfter("Client")
#doc.Close(False)
#word.Application.Quit()
if __name__ == '__main__':
parseData() |
Partager