title: Python Pandas XlsxWriter Center Across Selection
body: <p><strong>Background Info</strong></p>
  
  <p>I have a script which works fine for creating a merged header, but I need to center across selection instead of merging. I followed the official documentation, but it's not working. I've tried a large number of possible combinations, some of which I've included below in pictures. Any help would be greatly appreciated.</p>
  
  <p><strong>Code</strong></p>
  
  <p>I wrote the code such that you can just paste it in and run it with the exception of the <code>xlsFilepath</code>.  For now, I just hard-coded the text to center across the selection for simplicity but ideally I'm going to change this to the <code>Title</code> variable.</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  #Create a random dataframe for this example
  All_Columns_DF = pd.DataFrame(np.random.randn(100, 3), columns=['Title', 'Col_A' ,'Col_B'])
  
  #Set file path for local machine
  xlsFilepath = r'H:\myfile.xlsx'
  #Create writer
  writer = pd.ExcelWriter(xlsFilepath, engine='xlsxwriter')
  
  #Write the DF to excel
  All_Columns_DF.to_excel(writer, startrow = 1, sheet_name='Sheet1', index=False)
  #Extract the header from the DF which I want to Center Across Selection in Row 1
  Title_DF = All_Columns_DF[["Title"]]
  Title_DF_Unique = Title_DF.drop_duplicates()
  Title = Title_DF_Unique.iloc[0]['Title']
  
  #Define WB and WS
  workbook = writer.book
  worksheet = writer.sheets['Sheet1']
  
  #Start Formatting Attempt
  format = workbook.add_format()
  format.set_center_across()
  
  ''' Hard coding using row,col syntax does not work
  
  worksheet.write(1, 1, 'Center across selection', format)
  worksheet.write_blank(1, 2, '', format)
  '''
  
  '''Every combination of the below i try does not 
  center across the columns. Ive put write_blank above
  below, started at col A, B, etc, not thing ive tried
  works
  '''
  
  worksheet.write_blank("B1:F1", '', format)
  worksheet.write("A1", 'Center across selection', format)
  
  writer.save()
  </code></pre>
  
  <p><strong>Attempts</strong></p>
  
  <p><a href="https://i.stack.imgur.com/AsleJ.png" rel="nofollow noreferrer">Not Working</a></p>
  
  <p><a href="https://i.stack.imgur.com/31eHu.png" rel="nofollow noreferrer">Works but not centered</a></p>
  
  <p>Lastly, I want to stick with this package, so please do not recommend another package.</p>