I have two lists defined as:
Column1=[1,2,3,4]
Column2=[5,6,7,8]
I want to append the Column1
list to first column of an Excel sheet and the Column2
list to the second column of the Excel sheet. Excel sheet would look like:
My Code So Far:
from xlxswriter import*
workbook=Workbook('Ecl.xlxs')
Report_Sheet=workbook.add_worksheet()
for row_ind,row_value in enumerate(Column1):
print row_ind,row_value
Report_Sheet.write('A',Column1)#i want something similar to this
So each list should be appended to each column.
You could try with pandas like this:
import pandas as pd
df = pd.DataFrame.from_dict({'Column1':[1,2,3,4],'Column2':[5,6,7,8]})
df.to_excel('test.xlsx', header=True, index=False)
The test.xlsx
will be like the one you need.
Update:
import pandas as pd
Column1 = [1,2,3,4]
Column2 = [5,6,7,8]
df = pd.DataFrame.from_dict({'Column1':Column1,'Column2':Column2})
df.to_excel('test.xlsx', header=True, index=False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With