Answers for "python save excel file"

1

export_excel file python

df.to_excel(r'Path where you want to store the exported excel fileFile Name.xlsx', index = False)
Posted by: Guest on April-04-2020
3

python create excel file

from openpyxl import Workbook

filename = 'Testwriteexcel.xlsx'
sheettitle = 'Sheetname'

wb = Workbook()
wb['Sheet'].title = sheettitle
sh1 = wb.active
sh1['A1'].value = 'Numbers'
sh1['B1'].value = 'Sqares'
sh1['C1'].value = 'Column 3'

for n in range(1, 1+10):
    sh1[f'A{1+n}'].value = n
    sh1[f'B{1+n}'].value = n**2

try:
    wb.save(filename)
except PermissionError:
    print('File might be opened, please close it before writing')
Posted by: Guest on May-01-2021
-1

create excel file python

#import openpyxl  # Must be as least installed, import is optional
import pandas as pd
import numpy as np
# Create dataframe with your data; 
df = pd.DataFrame(np.array([[23, 99, 78], [65, 95, 90], [90, 98, 96]]), columns=['Bob', 'Dilan', 'Live'])
df
   Bob  Dilan  Live
0   23     99    78
1   65     95    90
2   90     98    96
# Export the dataframe as Excel File
# sheet_name="Your Sheet Name" is optionnal
df.to_excel(r'C:UsersRonDesktopFile_Name.xlsx', sheet_name="Your Sheet Name" ,index = False)
Posted by: Guest on July-23-2021

Python Answers by Framework

Browse Popular Code Answers by Language