title: Using custom styles defined in Excel with openxyl
body: <p>With <strong>openpyxl</strong>, you can use <a href="https://openpyxl.readthedocs.io/en/stable/styles.html#using-builtin-styles" rel="nofollow noreferrer">built-in styles</a> defined in Excel like such:</p>
  
  <pre><code>wb = load_workbook("My_Template.xlsx")
  ws = wb["My_super_Worksheet"]
  
  ws["B2"].value = '=Hyperlink("https://stackoverflow.com", "SO")'
  ws["B2"].style = "Hyperlink"
  </code></pre>
  
  <p>However, how would you use custom-styles defined in the Excel file? Something that could look like that:</p>
  
  <pre><code>wb = load_workbook("My_Template.xlsx")
  ws = wb["My_super_Worksheet"]
  
  wb.register_style("My_Custome_style")  # defined as custom style in My_Template.xlsx
  
  ws["B2"].value = '=Hyperlink("https://stackoverflow.com", "SO")'
  ws["B2"].style = ""My_Custome_style""
  </code></pre>
  
  <p>The only way I have found was to re-define the styles in your program as <a href="https://openpyxl.readthedocs.io/en/stable/styles.html#named-styles" rel="nofollow noreferrer">Named Styles</a> and save it but this would involve defining again the style instead of re-using what already exists.</p>
  
  <p>Thanks a lot.</p>