title: How to change column format in excel with python
body: <p>I want to copy an specific rows and columns one sheet to another with &quot;openpyxl&quot; method. But my main excel file is .xlsb file and &quot;openpyxl&quot; is not supporting .xlsb file.So I build that complicated way. (* I can not change the .xlsb from Microsoft Excel according to company rules).</p>
  <p><em>main document.xlsb file-&gt;temporary document.xlsx-&gt;my analyse document.xlsx</em></p>
  <p>-Firstly, I' m changing the data format .xlsb to .xlsx with pandas.</p>
  <p>-After that, from temporary document.xlsx, I' m taking specific columns and rows with openpyxl method and paste to my analyse document.xlsx</p>
  <p>-My question is: I want to change D column format from &quot;general&quot; to &quot;short date&quot; and I am beginner at Python. Would you please help me about codes?
  Also if I can change the format cell in &quot;.xlsb to .xlsx tranformation period&quot; maybe I can take input from user: &quot;which date do you want to append 'my analyse document.xlsx?'&quot;</p>
  <p><strong>'main document.xlsx'</strong></p>
  <p><a href="https://i.stack.imgur.com/NJvQH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NJvQH.png" alt="" /></a></p>
  <p><strong>'temporary document.xlsx'</strong></p>
  <p><a href="https://i.stack.imgur.com/1iD6q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1iD6q.png" alt="" /></a></p>
  <p><strong>'my analyse document.xlsx'</strong></p>
  <p><a href="https://i.stack.imgur.com/iOKo8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iOKo8.png" alt="" /></a></p>
  <pre><code>import pandas as pd
  import openpyxl
  
  df = pd.read_excel(&quot;main document.xlsb&quot;,sheet_name=&quot;Data&quot;, engine=&quot;pyxlsb&quot;)
  df.to_excel(&quot;temporary document.xlsx&quot;)
  
  #! Python 3
  # - Copy and Paste Ranges using OpenPyXl library
  
  # Prepare the spreadsheets to copy from and paste too.
  
  # File to be copied
  wb = openpyxl.load_workbook(&quot;temporary document.xlsx&quot;)  # Add file name
  sheet = wb[&quot;Sheet1&quot;]  # Add Sheet name
  
  # File to be pasted into
  template = openpyxl.load_workbook(&quot;my analyse document.xlsx&quot;)  # Add file name
  temp_sheet = template[&quot;Sheet2&quot;]  # Add Sheet name
  
  
  # Copy range of cells as a nested list
  # Takes: start cell, end cell, and sheet you want to copy from.
  def copyRange(startCol, startRow, endCol, endRow, sheet):
      rangeSelected = []
      # Loops through selected Rows
      for i in range(startRow, endRow + 1, 1):
          # Appends the row to a RowSelected list
          rowSelected = []
          for j in range(startCol, endCol + 1, 1):
              rowSelected.append(sheet.cell(row=i, column=j).value)
          # Adds the RowSelected List and nests inside the rangeSelected
          rangeSelected.append(rowSelected)
  
      return rangeSelected
  
  
  # Paste range
  # Paste data from copyRange into template sheet
  def pasteRange(startCol, startRow, endCol, endRow, sheetReceiving, copiedData):
      countRow = 0
      for i in range(startRow, endRow + 1, 1):
          countCol = 0
          for j in range(startCol, endCol + 1, 1):
              sheetReceiving.cell(row=i, column=j).value = copiedData[countRow][countCol]
              countCol += 1
          countRow += 1
  
  
  def createData():
      print(&quot;Processing...&quot;)
      selectedRange = copyRange(2, 2011, 183, 2274, sheet)  # Change the 4 number values (startCol, startRow, endCol, endRow, sheet)
      pastingRange = pasteRange(2, 4573, 182, 4836, temp_sheet, selectedRange)  # Change the 4 number values (startCol, startRow, endCol, endRow, sheet)
      # You can save the template as another file to create a new file here too.s
      template.save(&quot;my analyse document.xlsx&quot;)
      print(&quot;Range copied and pasted!&quot;)
  
  go= createData()
  </code></pre>