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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python openyxl not updating Excel file MrBean12 1 249 Mar-03-2024, 12:16 AM
Last Post: MrBean12
  Copy Paste excel files based on the first letters of the file name Viento 2 347 Feb-07-2024, 12:24 PM
Last Post: Viento
  Search Excel File with a list of values huzzug 4 1,147 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Updating sharepoint excel file odd results cubangt 1 753 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 704 Sep-22-2023, 02:33 PM
Last Post: carecavoador
  Copy data from Excel and paste into Discord (Midjourney) Joe_Wright 4 1,925 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,046 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  Save and Close Excel File avd88 0 2,840 Feb-20-2023, 07:19 PM
Last Post: avd88
  Trying to access excel file on our sharepoint server but getting errors cubangt 0 772 Feb-16-2023, 08:11 PM
Last Post: cubangt
  Import XML file directly into Excel spreadsheet demdej 0 800 Jan-24-2023, 02:48 PM
Last Post: demdej

Forum Jump:

User Panel Messages

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