Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
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 –  belisarius Jul 27 '12 at 4:26
@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. –  alancalvitti Jul 27 '12 at 19:52
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) –  belisarius Jul 27 '12 at 20:01
add comment

1 Answer

up vote 12 down vote accepted

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

share|improve this answer
+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? –  alancalvitti Jul 27 '12 at 19:53
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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