Is there a function to unhide columns in excel through python

0 votes

In order to maintain colour formatting, I turned an Excel spreadsheet into a DataFrame using StyleFrame. A few columns are already buried by default when I return to an Excel spreadsheet after converting this DataFrame.

This is my code:

import openpyxl
import pandas as pd
from StyleFrame import StyleFrame, Styler, utils  
sf = StyleFrame.read_excel("aaaa\\aaaa\\cdddd .xlsx",sheet_name = 2, read_style=True, header = None)
ew = StyleFrame.ExcelWriter('aaaa\\abbbbbb2.xlsx')
sf.to_excel(excel_writer = ew, header = False, index = False).save()

How do I make sure these columns are not hidden when opening the spreadsheet in Excel?

Oct 17, 2022 in Others by Kithuzzz
• 38,000 points
2,293 views

1 answer to this question.

0 votes

Excel file :

df.to_excel('demofile.xlsx',index=False)

import openpyxl

py = openpyxl.load_workbook('demofile.xlsx')
exlsheet = py.get_sheet_by_name('yoursheetName')

Checking Column

for col in exlsheet.columns:
  if not col[2].value:
    exlsheet.column_dimensions[col[2].column].hidden = True

Save your file

py.save('modifiedfile.xlsx')
answered Oct 18, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

Is there a way to test a formula result in excel and type it only once, all within one cell and not using a user defined function?

Use the Let function: =LET(Value,A1+B2+C4+G3+B4,IF(Value>10,"No",Value)) I hope this helps ...READ MORE

answered Jan 9, 2023 in Others by narikkadan
• 63,600 points
683 views
0 votes
1 answer

Is there a function in excel to automatically calculate age using date of birth?

Try  =INT((YEARFRAC(TODAY(),B3,1)))  Where cell B3 contains a date like ...READ MORE

answered Mar 28, 2023 in Others by Kithuzzz
• 38,000 points
628 views
0 votes
1 answer

Excel-VBA - How to identify Target range (more than 1 cell) is deleted in a Worksheet_Change function?

You misunderstand the purpose of the function ...READ MORE

answered Sep 23, 2022 in Others by narikkadan
• 63,600 points
3,755 views
0 votes
1 answer

Is there a way in Microsoft Excel to give specific bins different bin widths when making a histogram plot?

Excel built-in histogram tool only allows equal ...READ MORE

answered Oct 2, 2022 in Others by narikkadan
• 63,600 points
2,043 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,464 views
0 votes
1 answer
0 votes
1 answer

Is there any way in python to auto-correct spelling mistake in multiple rows of an excel files of a single column?

Use Spellchecker for doing your stuff: import pandas ...READ MORE

answered Oct 14, 2022 in Others by narikkadan
• 63,600 points
2,082 views
0 votes
1 answer

Is there a function in excel to find duplicates

Solution: You can use Conditional formatting inside the ...READ MORE

answered Nov 14, 2022 in Others by narikkadan
• 63,600 points
677 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP