# Possible to import Excel formatted text?

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

Yet

Import["/Users/alancalvitti/Dropbox/Understars/text.is.lyte/litany.of.\
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.

-
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

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:

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

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"]


% // InputForm


-
+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