python processing Excel xlrd

高洛峰
Release: 2016-10-18 10:35:26
Original
1510 people have browsed it

The module commonly used by python to process Excel is xlrd. It is very convenient to use xlrd to process Excel documents. The basic usage is introduced below

1. Open the file

import xlrd

data= xlrd.open_workbook("c:\skills.xls")

Get a worksheet

table = data.sheet_by_name(u'skills') #Also

table = data.sheet_by_index(0)

row, column acquisition

table.row_values(i)

table.col_values(i)

row Number, number of columns, etc.

nrows = table.nrows

ncols = table.ncols

Cell data

cell_A1 = table.cell(0, 0).value

cell_C4 = table.cell(2, 3) .value

#Simple write cell

table.put_cell(row, col, ctype, value, xf)

row = col = 0

ctype = 1 # 0 empty , 1 string, 2 number, 3 date, 4 bool, 5 error

value = 'this is cell value'

xf = 0


For more functions, please refer to the official documentation

https://secure.simplistix.co.uk/svn/xlrd/ trunk/xlrd/doc/xlrd.html?p=4966


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!