# Export Text with Colors

Is there a way of using Export[] method to take a text with colors (using Style) and then export to file, such that when I open that file the text shows with the correct color?

I'm trying to export a list of strings with some styles to be read in a text processor such as Microsoft Word.

• For starters you need so specify a file type that supports colors. pdf , html ? depends of what you are trying to do. – george2079 May 6 '15 at 18:36
• RTF format might be a good choice for opening in Word – Simon Woods May 6 '15 at 18:54
• Yeah, I think the same, but it is not woking, could you put some example, please. – Jonathan Prieto-Cubides May 6 '15 at 18:55

This seems to work:

list = Style @@@ ColorData["Crayola", "ColorRules"];

Export["test.rtf", Cell[BoxData @ ToBoxes @ #, "Output"] & /@ list]

• thanks, but it doesn't work too. Do you run it on OSX? I'm guessing that it could be a bug or something weird. – Jonathan Prieto-Cubides May 6 '15 at 21:15
• @d555, no I'm using Windows. Looks like you have a Mac specific bug... – Simon Woods May 6 '15 at 21:17

The challenge for me was concatenating styled strings. To concatenated the styled text for output, just put a space between them. With that the styles export successfully:

    Export["test.rtf",
Style["Arff", Red] Style["Meow", Blue]
]


That made the text is colored correctly when opened with Word on Windows. You can also try:

    Export["test.html",
Style["Arff", Red] Style["Meow", Blue]
]


Which might work cross platform - this file loaded okay in the IE, but not Word.

• Actually, your example it doesn't work too. I'm using Mathematica 10.1 on OS X 10.10 – Jonathan Prieto-Cubides May 6 '15 at 19:22
• I am using 10.1, but on Windows. I will try using an HTML file as the export... – xsk8rat May 6 '15 at 19:28
• the syntax here cant be right. – george2079 May 27 '15 at 1:23