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:

  • python read excel
  • python read xml
  • ole exception 16389
  • program to fetch data from xml and write in excel python
  • how to parce a excel.xml python
  • excel database python searching
  • self.__rowspython reading excel cell
  • excel 2003 xml python
  • parse xtml keywords excel
  • python reading excel document

No comments yet.

Leave a Comment