# -*- coding: utf-8 -*-
"""
Created on Thu May 24 13:53:10 2018 @author: Frank
""" import xlrd  #xlrd is a library for reading data and formatting information from Excel files, whether they are .xls or .xlsx files.

data = xlrd.open_workbook('通讯录.xlsx')#打开 Excel文件
print(type(data))
table = data.sheets()[0]
print(type(table))
nrows = table.nrows #行数
print("行数:{}".format(nrows))
ncols = table.ncols #列数
print("列数:{}".format(ncols))
for i in range(0,nrows):
rowValues = table.row_values(i) #某一行数据
#print(type(rowValues))
#print(rowValues)
print("姓名:{}<-->电话:{}".format(rowValues[0], rowValues[1]))

xlrd.open_workbook(filename=Nonelogfile=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>verbosity=0use_mmap=1file_contents=Noneencoding_override=Noneformatting_info=Falseon_demand=Falseragged_rows=False)

打开一个Excel文件。

这里先简单的介绍基本的参数,以后有用到再添加。

Parameters:

  filename – The path to the spreadsheet file to be opened.

    指定要打开文件的路径

  logfile – An open file to which messages and diagnostics are written  

Returns:

  An instance of the Book class.

book.sheets()

Return:  A list of all sheets in the book. 返回Excel中所有的表,并保存在list中。

  All sheets not already loaded will be loaded.

classxlrd.sheet.Sheet(bookpositionnamenumber)

Contains the data for one worksheet.

In the cell access functions, rowx is a row index, counting from zero, and colx is a column index, counting from zero. Negative values for row/column indexes and slice positions are supported in the expected fashion.

Note: You don’t instantiate this class yourself. You access Sheet objects via the Book object that was returned when you called xlrd.open_workbook().

nrows= 0

  Number of rows in sheet. A row index is in range(thesheet.nrows).

ncols= 0

  Nominal number of columns in sheet. It is one more than the maximum column index found, ignoring trailing empty cells. See also the ragged_rows parameter to open_workbook() and row_len().

row_values(rowxstart_colx=0end_colx=None)

  Returns a slice of the values of the cells in the given row.该函数返回一个list,默认包含这一行的cells的所有内容。

最新文章

  1. ZOJ Problem Set - 1350 The Drunk Jailer ac代码 memset
  2. 开发一个jQuery插件——多级联动菜单
  3. BIEE从底层表结构向上更新
  4. LeetCode | Regular Expression Matching
  5. [svn] 数据库操作残留,无法进行操作的解决方法
  6. Javascript数组的声明
  7. c++在string类源
  8. linux dd使用记录
  9. Material Design之NavigationView和DrawerLayout实现侧滑菜单栏
  10. [Swift]LeetCode988. 从叶结点开始的最小字符串 | Smallest String Starting From Leaf
  11. 一个tomcat下部署不同端口多个应用
  12. 使用JSDoc自动生成代码文档
  13. android页面渲染速度提升的常用方法
  14. 解决SharePoint 2010拒绝访问爬网内容源错误
  15. jQueryPrint 的简单使用
  16. [原][osg][oe]分析一块倾斜摄影瓦片的数据
  17. Java——文件及目录File操作
  18. JS拖拽元素原理及实现代码
  19. 几种在Linux下查询外网IP的办法(转)
  20. React脚手架create-react-app+elementUI使用

热门文章

  1. MFC进度条刷新处理
  2. LaTeX:Figures, Tables, and Equations 插入图表和公式
  3. Clone()方法C#
  4. python Parent.__init()和super(Child, self)的区别
  5. [Python爬虫] 之二十九:Selenium +phantomjs 利用 pyquery抓取节目信息信息
  6. css border-sizing 用法与理解
  7. 【实践】用for-in 循环实现三联联动
  8. android apktool 基本的安装与使用
  9. [CSS3] Make a One-time CSS Animation that Does Not Revert to its Original Style
  10. Linux下SVN部署/安全及权限配置,实现web同步更新