Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import openpyxl
- import os
- import glob
- path = os.getcwd()
- data=[]
- x=input('name:') + '.xlsx'
- target_xls = os.path.join(path,x)
- for file in glob.glob(path+'\*.*'):
- if file.endswith((".xlsx")):
- wb = openpyxl.load_workbook(file, data_only=True)
- for sheet in wb.worksheets:
- for j in range(2, sheet.max_row+1 ):
- for i in range(1,sheet.max_column+1):
- ihidden = sheet.row_dimensions[j].hidden # Row Visibility True / False
- svalue = sheet.cell(column=i,row=j).value
- if ihidden == True:
- shidden = "HIDDEN"
- else:
- shidden = "VISIBLE"
- data.append(svalue)
- WP= openpyxl.Workbook()
- ws = WP.active
- ws.title = "Sheet1"
- x=sheet.max_column
- new_list = [data[i:i+x] for i in range(0, len(data), x)]
- for elem in new_list:
- ws.append(elem)
- WP.save(target_xls)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement