Python Forum
copy/pasting in excel WHILE keep file format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
copy/pasting in excel WHILE keep file format
#1
Hi guys,

I would like to copy/paste some things in excel files BUT with keeping current format of the file.

The original file is in .xls and it has some macro inside of it.
While i run the code, it does the job and save it to .xlsx, however it loses completely format and macros.

What can i do to do this task and to keep the file format?

import pandas as pd

excel = pd.read_excel(PATH\Original_file.xls, header=None)
writer = pd.ExcelWriter(PATH\Test.xlsx", engine='xlsxwriter')

left_values = excel.loc[6:21, 16:22]
right_values = excel.loc[6:21, 30:36]
right_values = left_values

excel.to_excel(writer, 'sheet1', index=False, header=False)
In the attachment there is part of the original excel file

Attached Files

Thumbnail(s)
   
Reply


Messages In This Thread
copy/pasting in excel WHILE keep file format - by zarize - Jun-23-2020, 03:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is the copy method name in python list copy and not `__copy__`? YouHoGeon 2 289 Apr-04-2024, 01:18 AM
Last Post: YouHoGeon
  Python openyxl not updating Excel file MrBean12 1 345 Mar-03-2024, 12:16 AM
Last Post: MrBean12
  Copy Paste excel files based on the first letters of the file name Viento 2 455 Feb-07-2024, 12:24 PM
Last Post: Viento
  Search Excel File with a list of values huzzug 4 1,266 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Updating sharepoint excel file odd results cubangt 1 858 Nov-03-2023, 05:13 PM
Last Post: noisefloor
Thumbs Up Convert word into pdf and copy table to outlook body in a prescribed format email2kmahe 1 767 Sep-22-2023, 02:33 PM
Last Post: carecavoador
  Copy data from Excel and paste into Discord (Midjourney) Joe_Wright 4 2,078 Jun-06-2023, 05:49 PM
Last Post: rajeshgk
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,119 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  Save and Close Excel File avd88 0 3,084 Feb-20-2023, 07:19 PM
Last Post: avd88
  Trying to access excel file on our sharepoint server but getting errors cubangt 0 824 Feb-16-2023, 08:11 PM
Last Post: cubangt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020