excel
Example heading with h2 size
Example heading with h3 size
Following is sample java code.
def generate_new_excel(high_beam_path, values_path, output_path='results.xlsx'):
# Load the Excel files with headers
high_beam_df = pd.read_excel(high_beam_path, header=None, engine='openpyxl')
values_df = pd.read_excel(values_path, engine='openpyxl')
# Initialize a list to store the output rows
output_rows = []
# Copy A1 to I11 from high_beam_df
output_rows.extend(high_beam_df.iloc[0:11].values.tolist())
# Get the repeating template from A12 to I17
repeating_template = high_beam_df.iloc[11:17].values.tolist()
# Get the final part from A17 to I21
final_part = high_beam_df.iloc[17:21].values.tolist()
# Counter for incrementing Nxxx
counter = 1
# Loop through the rows in values_df to create the repeated section
for _, row in values_df.iterrows():
for template_row in repeating_template:
new_row = template_row.copy()
for idx, value in enumerate(new_row):
if idx == 2 and value in ['vol_write', 'ExtNtc_write', 'InNtc_write', 'LED_read']:
if value == 'vol_write':
new_row[5] = row['vol_write']
elif value == 'ExtNtc_write':
new_row[5] = row['ExtNtc_write']
elif value == 'InNtc_write':
new_row[5] = row['InNtc_write']
elif value == 'LED_read':
new_row[5] = row['LED_read']
output_rows.append(new_row)
# Add the final part (A17 to I21)
output_rows.extend(final_part)
# Create a new DataFrame for the output
output_df = pd.DataFrame(output_rows)
# Save the DataFrame to an Excel file with headers
output_df.to_excel(output_path, header=False, index=False)
print("Successful")
# Define the paths for the input files
high_beam_path = r"C:\Users\abhik\OneDrive\Desktop\pyScript\excelManipulation\High_Beam_TL.xlsx"
values_path = r"C:\Users\abhik\OneDrive\Desktop\pyScript\excelManipulation\values.xlsx"
# Generate the new Excel file
generate_new_excel(high_beam_path, values_path)