打开excel文件读取数据
            
              data = xlrd.open_workbook("excelFile.xls")
            
          
读取工作表
            
              table = data.sheets()[0]
            
             # 通过索引顺序获取
          
            
              table = data.sheet_by_index(0)
            
             # 通过索引顺序获取
          
            
              table = data.sheet_by_name(u'Sheet1')
            
             # 通过名称获取
          
获取整行和整列的值(数组)
            
              table.row_values(i)
            
             #获取整行值
          
            
              table.col_values(i)
            
             #获取整列的值
          
获取行数和列数
            
              nrows = table.nrows
            
             #获取行数
          
            
              ncols = table.ncols
            
             #获取列数
          
###单元格
            
              cell_A1 = table.cell(0,0).value
            
          
            
              cell_C4 = table.cell(2,3).value
            
          
使用行列索引
            
              cell_A1 = table.row(0)[0].value
            
          
            
              cell_A2 = table.row(1)[0].value
            
          
            
              
                # -*- coding: utf-8 -*-
              
              
                import
              
               xlrd
              
                def
              
              
                excel_data
              
              
                (
              
              
                file
              
              
                =
              
              
                'test.xls'
              
              
                )
              
              
                :
              
              
                try
              
              
                :
              
              
                # 打开Excel文件读取数据
              
              
        data 
              
                =
              
               xlrd
              
                .
              
              open_workbook
              
                (
              
              
                file
              
              
                )
              
              
                # 获取第一个工作表
              
              
        table 
              
                =
              
               data
              
                .
              
              sheet_by_index
              
                (
              
              
                0
              
              
                )
              
              
                # 获取行数
              
              
        nrows 
              
                =
              
               table
              
                .
              
              nrows
        
              
                # 获取列数
              
              
        ncols 
              
                =
              
               table
              
                .
              
              ncols
        
              
                # 定义excel_list
              
              
        excel_list 
              
                =
              
              
                [
              
              
                ]
              
              
                for
              
               row 
              
                in
              
              
                range
              
              
                (
              
              
                0
              
              
                ,
              
               nrows
              
                )
              
              
                :
              
              
                for
              
               col 
              
                in
              
              
                range
              
              
                (
              
              ncols
              
                )
              
              
                :
              
              
                # 获取单元格数据
              
              
                cell_value 
              
                =
              
               table
              
                .
              
              cell
              
                (
              
              row
              
                ,
              
               col
              
                )
              
              
                .
              
              value
                
              
                # 把数据追加到excel_list中
              
              
                excel_list
              
                .
              
              append
              
                (
              
              cell_value
              
                )
              
              
                return
              
               excel_list
    
              
                except
              
               Exception 
              
                as
              
               e
              
                :
              
              
                print
              
              
                (
              
              
                str
              
              
                (
              
              e
              
                )
              
              
                )
              
              
                if
              
               __name__ 
              
                ==
              
              
                "__main__"
              
              
                :
              
              
                list
              
              
                =
              
               excel_data
              
                (
              
              
                )
              
              
                for
              
               i 
              
                in
              
              
                list
              
              
                :
              
              
                print
              
              
                (
              
              i
              
                )
              
            
          
        


 
					 
					