Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

285
Visualizações
Hide columns when using to_excel

I have two DataFrames, each with multiple columns.

I am saving these to Excel in different sheets.

For the dir_tree_df dataframe, I would like the first 3 sheets hidden. For the table_of_contents_df dataframe, I would like the first column hidden.

Is this possible? I've seen a possible solution here, but unsure how to implement it in my code

Is it possible to create an excel file with hidden columns in Python using pandas?

My Code

 with pd.ExcelWriter(target_directory + 'output_test.xlsx') as writer:  
        table_of_contents_df.to_excel(writer, sheet_name='Contents', index = False)
        dir_tree_df.to_excel(writer, sheet_name='Data', index = False)
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Think I solved it. The docs helped:
https://xlsxwriter.readthedocs.io/working_with_pandas.html https://xlsxwriter.readthedocs.io/worksheet.html#worksheet

with pd.ExcelWriter(target_directory + 'output_test.xlsx', engine = 'xlsxwriter') as writer:  
            table_of_contents_df.to_excel(writer, sheet_name='Contents', index = False)
            dir_tree_df.to_excel(writer, sheet_name='Data', index = False)
    
            worksheet = writer.sheets['Contents']
            worksheet.set_column('A:A', None, None, {'hidden': 1})
    
            worksheet = writer.sheets['Data']
            worksheet.set_column('A:C', None, None, {'hidden': 1})
            
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda