wb = Workbook("input file location")
ws = wb.getWorksheets()
sheet_count = ws.getCount()
for i in range(0,sheet_count):
sheet_name = ws.get(i).getName()
print(sheet_name)
Hi @Amjad_Sahi
above is my code as you have asked for and i am getting one sheet name at a time trying to use that but i want whole name as a list is their any way
so please help me out with this and also please tell me the function using which i can clear the content of the excel sheet, i have tried using Clear() function to remove the content of the sheet but it is showing error.
btw thank you so much for your help and time.
@asposeLegit
You can add every sheet name to a list:
# sheet name list
sheet_names = []
for i in range(0, sheet_count):
sheet_name = ws.get(i).getName()
sheet_names.append(sheet_name)
print(sheet_names)
Please try the following code to remove cells, shape, chart and picture in a sheet:
# clear content of a sheet(e.g. the first sheet)
first_sheet = wb.getWorksheets().get(0)
# clear cell
first_sheet.getCells().clear()
# clear shape, chart and picture
first_sheet.getShapes().clear()
1 Like
thank you so much, ur advice work perfectly, just one thing if i have to copy and paste chart format what should i and how to remove the border of the chart?
@asposeLegit,
See the document on how to copy shapes b/w worksheets for your reference.
To remove or hide borders of the chart area/plot area, you may try the following lines of code:
chart.getPlotArea().getBorder().setVisible(false);
cart.getChartArea().getBorder().setVisible(false);
chart.getChartArea().getBorder().setWeight(0);
chart.getPlotArea().getBorder().setTransparency(1);
Hope, this helps a bit.