SHARE
TWEET

Untitled

a guest Feb 20th, 2020 173 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top