pandas icon indicating copy to clipboard operation
pandas copied to clipboard

ENH: allows word / PPT / outlook formatting as output of to_clipboard

Open lcrmorin opened this issue 2 years ago • 2 comments

Feature Type

  • [X] Adding new functionality to pandas

  • [ ] Changing existing functionality in pandas

  • [ ] Removing existing functionality in pandas

Problem Description

The function to_clipboard allow to copy a dataframe, then paste it. It has an option to format the data such as it is pastable directly into Excel. However it doesn't allow to paste the data into MS Word / Powerpoint / Outlook. Also - it might be a different issue - but it would be very nice to be able to copy style, as currently to_clipboard throws an error on a styler object.

Best, Lucas

Feature Description

  • allows to clipboard to works on styler objects
  • allows and option in to_clipboard to copy_paste to MS word / outlook / ppt

Alternative Solutions

current solution is to use pyperclip then copy paste into excel then into MS word / outlook / ppt

Additional Context

No response

lcrmorin avatar Feb 08 '24 10:02 lcrmorin

Thanks for the request. Is there a suggested implementation? Here is the implementation for excel=True

if sep is None:
    sep = "\t"
buf = StringIO()

# clipboard_set (pyperclip) expects unicode
obj.to_csv(buf, sep=sep, encoding="utf-8", **kwargs)
text = buf.getvalue()

clipboard_set(text)

It seems to me an implementation for Word, PowerPoint, Outlook, and other applications would be much more effort and outside the scope of pandas.

rhshadrach avatar Feb 09 '24 22:02 rhshadrach

I am trying to understand what would be needed. I am asking here and there and will propose something when I figure out what would word need.

lcrmorin avatar Feb 15 '24 07:02 lcrmorin

I don't think that we want to take on the burden of maintaining compatibility with these formats, this would need a 3rd party package that we could dispatch to

phofl avatar Mar 18 '24 01:03 phofl