Hi,
I'm trying to create a report of the following format.
Could someone please help me with this
Hi @nkrupabd ,
I have updated the python code to read file from input.
Please find the update code below.
from ayx import Alteryx
import xlsxwriter
import pandas as pd
df=Alteryx.read("#1")
workbook = xlsxwriter.Workbook('C:\\Community\\Example3.xlsx')
cell_format = workbook.add_format({'bold': True,'border': 1})
cell_border = workbook.add_format({'border': 1})
for i,rows in df.iterrows():
dfLine5=rows[['Old payrate','Date of payrate change','Date of payrate change']].copy()
dfLine9=rows[['New payrate','Date of payrate change','Date of payrate change']].copy()
i=workbook.add_worksheet(rows[0])
row = 1
col = 1
#Dynamically generate sheets from input dataset
for d in rows:
i.write(row, col, d,cell_border)
col += 1
#Line 5
Line5 = ['Old payrate','Date of payrate change','End Date']
row = 5
col = 3
# Iterate over the data and write it out row by row.
for header in (Line5):
#worksheet.write(row, col, df[index])
i.write(row, col, header,cell_format)
col += 1
rowV = 5
colV = 3
for j in dfLine5:
i.write(rowV+1, colV, j,cell_border)#worksheet.write(row+1, col+1, value)
colV += 1
# Line 9 Datarow Manipulation
Line9 = ['New payrate','Date of payrate change','End Date']
L9row = 5
L9col = 12
# Iterate over the data and write it out row by row.
for header in (Line9):
#worksheet.write(row, col, df[index])
i.write(L9row, L9col, header,cell_format)
L9col += 1
L9rowV = 5
L9colV = 12
for j in dfLine9:
i.write(L9rowV+1, L9colV, j,cell_border)#worksheet.write(row+1, col+1, value)
L9colV += 1
workbook.close()
output
Thanks.