I am looking for something like the html <b> text formatter (and others for color) to paste text into Excel, so that Excel recognizes it as "formatted" and displays it as such.

My sepcific problem is that I have a plain text in my clipboard (copied from a sublcass of a python PyQt QTableWidget, but I don't think that's relevant) that basically looks like this:


That when copied to the clipboard converts the \t and \n to give a nicely formatted:

    Header1 Header2
RowHeader1  0.23    0.45
RowHeader2  0.1 1.3

which when pasted into Excel looks like this:

Excel Raw

Now I have three problems:

  1. (German) Excel recognizes one of the numbers as a date. I know I can go to paste options now and tell Excel to treat everything as text. But is there a way I can change the plain text so that Excel already knows it should treat it as text?
  2. I would like the headers to be in bold text. Is there any way I can change the plain text (not afterwards in Excel) so that Excel knows when it's being pasted to make it bold? I naively tried that html formatter <b>, which didn't work.
  3. Some of the numbers background should be red. Again, is there a way to change the plain text so that Excel automatically makes them red after pasting?

So to summarize, how can I change this:


So that when pasted into Excel it automatically looks like this:

Excel Formatted

  • You could create like a template with conditional formattin rules that apply bold format to all cells in Column A if any contains the text "RowHeader", or to Row 1 If any cell contains text "Header". That would be an option, but not sure if it's the best one. – Foxfire And Burns And Burns Jun 7 at 10:47
  • Unfortunately „RowHeader“ is only a sample text so that wouldn’t work. And I have a lot of things that I want to copy with a lot of different conditions, so using a template is not really feasible. – Freya W Jun 8 at 12:00
  • There are not a ny single condition common to all those things? Or even a condition that says "If the cell is not empty, make the text bold" ? that would work for any kind of text, for column A and for headers. – Foxfire And Burns And Burns Jun 10 at 8:28
  • No, no single conditions. Sometimes the columns have to have values > 1 marked, sometimes they have to have values > 1.1 marked red... all that logic is inside the python program and can't really be transferred to an Excel template. Some row headers will be bold, others should be normal font. – Freya W Jun 12 at 11:03
  • all that logic is inside the python program well, then you'll have to use Python to get the format, or develop all that logic into an VBA macro that suits that logical formatting. With normal use of Excel you can't get what you want. – Foxfire And Burns And Burns Jun 12 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.