Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import openpyxl
  2. import os
  3. import glob
  4.  
  5.  
  6. path = os.getcwd()
  7. data=[]
  8. x=input('name:') + '.xlsx'
  9. target_xls = os.path.join(path,x)
  10. for file in glob.glob(path+'\*.*'):
  11. if file.endswith((".xlsx")):
  12. wb = openpyxl.load_workbook(file, data_only=True)
  13. for sheet in wb.worksheets:
  14. for j in range(2, sheet.max_row+1 ):
  15. for i in range(1,sheet.max_column+1):
  16. ihidden = sheet.row_dimensions[j].hidden # Row Visibility True / False
  17. svalue = sheet.cell(column=i,row=j).value
  18. if ihidden == True:
  19. shidden = "HIDDEN"
  20. else:
  21. shidden = "VISIBLE"
  22. data.append(svalue)
  23. WP= openpyxl.Workbook()
  24. ws = WP.active
  25. ws.title = "Sheet1"
  26. x=sheet.max_column
  27. new_list = [data[i:i+x] for i in range(0, len(data), x)]
  28. for elem in new_list:
  29. ws.append(elem)
  30. WP.save(target_xls)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement