파이썬 엑셀처리
import xlrd
wb = xlrd.open_workbook("c:/Book1.xls")
sh = wb.sheet_by_index(0)
print wb.nsheets, wb.sheet_names()
print sh.name, sh.cell_value(0,1)
wb = xlrd.open_workbook("c:/Book1.xls")
sh = wb.sheet_by_index(0)
print wb.nsheets, wb.sheet_names()
print sh.name, sh.cell_value(0,1)
2. pywin32 (읽기/쓰기 - COM 이용)
홈페이지 : https://sourceforge.net/projects/pywin32/
from win32com.client import Dispatch
xl = Dispatch("Excel.Application")
wb = xl.Workbooks.Open("c:/Book1.xls")
sh = wb.Sheets[0]
sh.Cells(2,1).Value = 'pywin32'
print wb.name, sh.name, sh.cells(1,2).value
wb.save
wb.close
xl.quit()
del xl
xl = Dispatch("Excel.Application")
wb = xl.Workbooks.Open("c:/Book1.xls")
sh = wb.Sheets[0]
sh.Cells(2,1).Value = 'pywin32'
print wb.name, sh.name, sh.cells(1,2).value
wb.save
wb.close
xl.quit()
del xl
댓글
댓글 쓰기