วันศุกร์ที่ 5 กรกฎาคม พ.ศ. 2556

Excel in Python

detail here >> http://stackoverflow.com/questions/3504604/recommend-a-python-library-to-read-excel-xls-files
official document for xlrd here >> https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html?p=4966

1. install
    easy_install xlrd
    easy_install xlwt
    easy_install xlutils

2. register to Eclipse
  go to menu Window > Preferences > PyDev > Interpreter-Python
  click button 'New Folder' to add
  /usr/local/lib/python2.7/dist-packages/xlrd-0.9.2-py2.7.egg
  /usr/local/lib/python2.7/dist-packages/xlutils-1.6.0-py2.7.egg
  /usr/local/lib/python2.7/dist-packages/xlwt-0.7.5-py2.7.egg

3. sample code to read from Excel file
    import xlrd

    book = xlrd.open_workbook('myfile.xls')

    print book.nsheets
    print book.sheet_names()

    sh = book.sheet_by_index(0)
    print sh.name, sh.nrows, sh.ncols



ไม่มีความคิดเห็น:

แสดงความคิดเห็น