Is it possible to import Excel text markup such as underlines? For example:

enter image description here


duals/litany.of.duals.xlsx"][[1, 1]]

returns a list with the plain string:

{"nyt 7.23.12", "question for a ceo: what is yahoo?", "17 years after \
the company was founded, you still have to wonder whether the frothy \
trademark yahoo! should be replaced with yahoo? to convey the \
uncertainty of purpose", "david carr @nyt"}

Note that the formatting is partial, not a global formatting selection (such as font) that affects the whole cell.

  • 1
    $\begingroup$ I don't like this solution for a lot of reasons, but if you save your excel file as xml and read it with Cases[Import["c:\\test3.xml", "xml"], XMLElement["Cell", _, _], Infinity], the formatting is there $\endgroup$ Jul 27, 2012 at 4:26
  • $\begingroup$ @belisarius, at the moment this is the only solution. If it's possible to programmatically convert xsl/xlsx --> xml in MMA itself (as a temporary variable) I'll accept that answer if you submit it as such. $\endgroup$ Jul 27, 2012 at 19:52
  • $\begingroup$ As I said, I don't like it. Perhaps it is possible, but I am sure a lot of things will break in the process. If you absolutely need some emergency code, you have this. But it is just that, a dirty fix. (BTW, that is why I didn't post it as an answer) $\endgroup$ Jul 27, 2012 at 20:01

1 Answer 1


Mathematica can import formatted text. But there is a small catch. Looks like we can import format applied to an Excel cell as whole, but not formatting of a part of text inside the cell. At least I did not find any options for this. Here is an example.

A lot of formatting was applied to part of text in the last cell, which you can see in Excel properties when only that part is selected:

enter image description here

If on other hand you click on the cell as whole, Excel properties show original formatting as property of the whole cell:

enter image description here

I guess, this is why, Mathematica did not import partial formatting - it picked up formatting properties of the whole cell provided by Excel:

Import["test.xlsx", "FormattedData"]

enter image description here

% // InputForm

enter image description here

  • 1
    $\begingroup$ +1 Vitaliy, for the explanation. Unfortunately It doens't help the situation at hand which is to recover partial formatting not for the whole cell (editing my original Q to reflect this). Is belisarius' xml "hack" the only solution then? $\endgroup$ Jul 27, 2012 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.