One , Basic environment

       1, my python The environment is 3.0 Above ,excel yes 2016 edition , For software pycharm

Two , Specific use

        1, You need to download it first openpyxl 

          pip install openpyxl 

          2, Some simple knowledge points

           a, Open what you need to open excel And instantiate one worksheet               
wb=load_workbook(r' Your catalogue ')
             b, Get current sheet page ( You can also specify )

               sheet=wb.active

              c,  Get the row range you need , Note that cell coordinates are always from the (1,1) start , non-existent (0,1) perhaps (1,0)

                    Otherwise, it will report an error 'ValueError: Row or column values must be at least 1'

                  The scope is guaranteed at  range(1,sheet.max_row+1) that will do

               d, Get one individually cell Value of

                   cell1=sheet.cell(row=row,column=1).value   
#value It's necessary , Otherwise, you get the cell object , Not the specific value

            The specific simple code is as follows :

                          
def getdata(baseurl,f): #list=[] wb=load_workbook(baseurl) sheet=wb.active
#sheet.values(row) for row in range(1,sheet.max_row+1): temp_list=[]
cell1=sheet.cell(row=row,column=1).value
cell2=sheet.cell(row=row,column=2).value temp_list=[cell1,cell2]
print('cell2=%s cell1=%s'%(cell2,cell1))
 

   

Technology
©2019-2020 Toolsou All rights reserved,
VUE+Canvas Achieve desktop Pinball brick elimination games C/C++ Memory model 2019PHP Interview questions ( Continuously updated )PHPspringboot2 Separation of front and rear platforms ,token Put in header Pit for verification Vue SpringBoot conduct Excel download element-ui Step on pit record 45 The 12-year-old programmer was turned down , Is the workplace wrong ?Python Web frame Pandas Fundamentals of statistical analysis _ data processing (DataFrame Common operations )Java Misunderstanding —— Method overloading is a manifestation of polymorphism ?