I'm looking for a way to preserve italicized text when exporting from XLSX to CSV. I know CSV doesn't support styled text, but I'm wondering if anyone knows of a workaround. For instance, does Excel have a way of converting selected cells to HTML? (Wrapping the italicized text in em tags would solve my problem.)

UPDATE: Thought I should clarify, my intention is to import the CSV into a MySQL database through a PHP script, and output as HTML.

Another UPDATE: I'm using Excel 2008 for Mac.

link|improve this question
feedback

3 Answers

up vote 1 down vote accepted

So this is basically what I was looking for:

http://www.xlmacros.com/content/how-search-italic-text-range-using-excel-vba

It's a VBA script that will wrap <em> tags (or actually <i> tags) around italicized text in cells. That way, I can export as CSV, and then just dump that text straight into a database table, with no complex parsing, but preserving italics. It requires a Windows version of Excel, or (presumably) the new 2010 Mac version, which is supposed to support macros.

Or maybe some AppleScript genius could figure it out. I'll probably just try to get on Windows Excel for a bit and see if this script works.

link|improve this answer
feedback

It sounds easier to just open the file in OpenOffice.org Calc and do the HTML conversion in there.

link|improve this answer
I'm looking at Calc right now, but I'm not seeing any HTML conversion options... – handsofaten Oct 19 '10 at 22:04
One of the export formats here (3.1.1) is XHTML. – Ignacio Vazquez-Abrams Oct 19 '10 at 22:09
I see what you mean. But parsing this kind of XHTML is going to make things a lot more complex (maybe not quite as bad as the Excel 2004 XML...) – handsofaten Oct 20 '10 at 3:32
You could process it (or the Excel output mind you, or even the raw MSOXML) in XSLT to strip out the unneeded parts. – Ignacio Vazquez-Abrams Oct 20 '10 at 3:36
feedback

Export to XML.

link|improve this answer
Yikes. I thought this was a good idea at first, but then I looked at the actual XML. (I'm using Excel 2008 Mac, and the only XML export option is the 2004 XML format). Lots of insane <FONT> tags and <I> tags and other nonsense. Thanks for the idea, though. – handsofaten Oct 19 '10 at 21:25
@handofaten, hmmm, maybe you could write a conversion script for it and make millions. – Lance Roberts Oct 19 '10 at 21:37
Gotta be easier ways to make millions... – handsofaten Oct 20 '10 at 3:44
feedback

Your Answer

 
or
required, but never shown

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