0

I have some problems to extract the format and data of the template sheet. At the moment with my code I can extract only the data values.

import pandas as pd

template = pd.read_excel('Template_sugerencia.xlsx', sheet_name='template')
writer = pd.ExcelWriter('Completo.xlsx', engine='xlsxwriter')
template.to_excel(writer, sheet_name='Recomendaciones', startcol=5, startrow=Recom_len, index=False)
writer.save()
  • Possible duplicate of [pandas read excel as formatted](https://stackoverflow.com/questions/38038428/pandas-read-excel-as-formatted) – patrickjlong1 Feb 16 '18 at 21:04

1 Answers1

1

I don't think it's possible to extract the format using pandas.
But what you could do instead is format your sheet once the data has been extracted .
See below:

workbook  = writer.book
worksheet = writer.sheets['Recomendaciones']

format_xl = workbook.add_format({
    'font_name': 'Arial',
    'font_size' : 12,
    'font_color': 'red',
    })

#           Args => (<range>, <col width>, <css>)
worksheet.set_column('A:ZZ', None, format_xl)
smallwat3r
  • 1,037
  • 1
  • 8
  • 28