Excel won't apply multiple "formats" to a cell in the sense that cell
formatting includes alignment, borders, and background. All you can vary
is the font and associated attributes, and only in a constant text cell.
Thus you could't get subscripting applied to your '0' if the 'X0' was
the result of a formula e.g. ="X"&"0".
MS Office doesn't believe in denormalisation. It has this concept of
"Rich Text", where the font etc attributes are carried around with the
text itself, to the extent that "X0"[vanilla] and "X0"[subscript from
offset 1 onwards] are two separate entries in an Excel file's SST
(shared string table).
xlwt doesn't support this.
OTTOMH, the code you would need if it did support it might look
something like this:
normal_style = xlwt.easyxf("font: name Times New Roman, height 200")
font_sub = xlwt.easyfont("escapement subscript")
font_uline_big = xlwt.easyfont("underline on, height 400")
rt = [
"Rich Text Demo: X",
("0", fnt_sub),
" and some more normal text ",
("and some 20pt underlined text", font_uline_big),
" and final normal text",
]
worksheet.write_rich_text(0, 0, rt, normal_style)
Anyone interested in the data structures should read sections
2.5.1 Formatting Runs
2.5.3 Unicode Strings (BIFF8)
4.11.1 The SST Record
5.21 CONTINUE
5.100 SST – Shared String Table
of http://sc.openoffice.org/excelfileformat.pdf
Cheers,
John
That's great, Rob. Yes, please, a patch against the latest source
(version 0.7.0) would be appreciated. Copies of test scripts (especially
ones that check proper CONTINUE operation on large SSTs) would be good
too.
Cheers,
John