Excel OpenXML #.
Excel ASCII.
- , , -.
, Microsoft DocumentFormat.OpenXML OpenXML SDK 2.0, - .
:
t.Text = Regex.Replace(sValue, @"[\x00-\x08]|[\x0B\x0C]|[\x0E-\x19]|[\uD800-\uDFFF]|[\uFFFE\uFFFF]", "?");
sValue, . .
XML 0x09 (TAB), 0x0A (LF - NL - ) 0x0D (CR - ). RegEx .
XML 1.1 .
For example: Using  for 0x03 appears as in HTML and as L in Office documents and notepad.
Asp.net, GridView, , , , , .
I thought of escaping these values in OpenXML, but when looked at the output, it showed the excape markup. So MikeTeeVee still shows up as MikeTeeVee in Excel instead of something like MikeTeeVee, or Mike LTeeVee. This is why preferred the Mike?TeeVee approach.
- OpenXML, ASCII XML, ASCII.
UPDATE:
, , " Open XML SDK 2.0", , Excel.
, : _x0000 _
: XML 1.0 , XML 1.1 , , 1.1, , .
XML 1.1 :
t.Text = Regex.Replace(s, @"[\x00-\x08]|[\x0B\x0C]|[\x0E-\x19]|[\uD800-\uDFFF]|[\uFFFE\uFFFF]",
delegate(Match m)
{
return (byte)(m.Value[0]) == 0
? ""
: ("&#x" + string.Format("{0:00}", (byte)(m.Value[0])) + ";");
});
OpenXML, :
t.Text = Regex.Replace(s, @"[\x00-\x08]|[\x0B\x0C]|[\x0E-\x19]|[\uD800-\uDFFF]|[\uFFFE\uFFFF]",
delegate(Match m)
{
return (byte)(m.Value[0]) == 0
? ""
: ("_x" + string.Format("{0:0000}", (byte)(m.Value[0])) + "_");
});