(python2.7.x)
Install
$ pip install xlrd
Source code
import xlrd def get_sheet_lines(xlsx_filename, sheet_name, num_of_header_lines=1): book = xlrd.open_workbook(xlsx_filename) sheet = book.sheet_by_name(sheet_name.decode('utf8')) lines = [] for row in range(sheet.nrows): line = [] for col in range(sheet.ncols): line.append(sheet.cell(row, col).value) lines.append(line) lines = lines[num_of_header_lines:] return lines print(get_sheet_lines('file.xlsx', 'sheet name'))
- ファイル名は utf8
- シート名は unicode