Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Python: How to read Microsoft Excel XML document

Python: How to read Microsoft Excel XML document
{filelink=16808}

import sys
from xml.sax import saxutils, parse
class ExcelHandler(saxutils.DefaultHandler):
    def __init__(self):
        self.chars = [  ]
        self.cells = [  ]
        self.rows = [  ]
        self.tables = [  ]
    def characters(self, content):
        self.chars.append(content)
    def startElement(self, name, atts):
        if name=="Cell":
            self.chars = [  ]
        elif name=="Row":
            self.cells=[  ]
        elif name=="Table":
            self.rows = [  ]
    def endElement(self, name):
        if name=="Cell":
            self.cells.append(''.join(self.chars))
        elif name=="Row":
            self.rows.append(self.cells)
        elif name=="Table":
            self.tables.append(self.rows)
if _ _name_ _ == '__main__':
    excelHandler = ExcelHandler( )
    parse('excel.xml', excelHandler)
    print excelHandler.tables

Users who found this page were searching for:

  • read excel array python
  • python reading excel document
  • python read cell excel xml
  • importar xml a excel con python
  • program to fetch data from xml and write in excel python
  • self.__rowspython reading excel cell
  • excel 2003 xml python
  • python read excel formula
  • python read Excel xml
  • python read excel

No comments yet.

Leave a Comment