title: How to read visible-only cells using Python?
body: <p>I want to read and merge only visible cells in Excel, but I failed.</p>
  
  <p>Also, I've tried <code>openpyxl</code> but didn't work. (Find my second code)</p>
  
  <p>Is there any other ways to read only visible cells and paste on new excel?</p>
  
  <p>I want to read only visible cells because sometimes they need to be filtered or hidden.</p>
  
  <p>Please kindly advise me.</p>
  
  <p>What kind of module should I put in?</p>
  
  <p>If every excel module cannot do that, please also let me know.</p>
  
  <p>My current code:</p>
  
  <pre><code>import os
  import glob
  import xlwings as xw
  import xlrd
  import xlsxwriter
  
  
  xw.App().visible = False
  path = os.getcwd()
  x=input('name：') + '.xlsx'
  target_xls = os.path.join(path,x)
  data = []
  for file in glob.glob(path+'\*.*'):
      if file.endswith((".xls", ".xlsm", ".xlsx")):
  
          wb = xlrd.open_workbook(file)
          for sheet in wb.sheets():
              for rownum in range(sheet.nrows):
                  data.append(sheet.row_values(rownum))
          workbook = xlsxwriter.Workbook(target_xls)
          worksheet = workbook.add_worksheet()
          for i in range(len(data)):
              print(range(len(data)))
              for j in range(len(data[i])):
                  worksheet.write(i, j, data[i][j])
          workbook.close()
  </code></pre>
  
  <p>My openpyxl code:</p>
  
  <pre><code>import os
  import glob
  import xlwings as xw
  import xlrd
  import xlsxwriter
  
  
  from openpyxl import load_workbook
  xw.App().visible = False
  path = os.getcwd()
  x = input('name：') + '.xlsx'
  target_xls = os.path.join(path, x)
  data = []
  wb = load_workbook('sample.xlsx') 
  ws = wb['Sheet1']
  
  for row in ws:
  
      if ws.row_dimensions[row[0].row].hidden == False:
          for cell in row:
              data.append(cell.value)
      workbook = xlsxwriter.Workbook(target_xls)
      worksheet = workbook.add_worksheet()
  
      for i in range(len(data)):
          print(range(len(data)))
          for j in range(len(data[i])):
              worksheet.write(i, j, data[i][j])
      workbook.close()
  </code></pre>
  
  <p>I want to read excel like below:</p>
  
  <p><a href="https://i.stack.imgur.com/mFCQC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mFCQC.png" alt="enter image description here"></a></p>
  
  <p>And output into:</p>
  
  <p><a href="https://i.stack.imgur.com/UY0bo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UY0bo.png" alt="enter image description here"></a></p>