Note that there are some explanatory texts on larger screens.

plurals
  1. POOOXML SDK illegal character replacements
    primarykey
    data
    text
    <p>I am having an issue with creating an XLSX document with the Open XML SDK 2.0 from MS.</p> <p>My issue is that I need to display some of these illegal characters in the excel sheet, but if I just add them to the sheet, the document will not load.</p> <p>I am using this function </p> <pre><code> private static string ProcessString(string str) { return System.Security.SecurityElement.Escape(str); } </code></pre> <p>Which will give me Tom&amp;apos;s ball instead of Tom's ball. (Well I haven't figured out how to get the latter as the excel generated won't open.)</p> <p>Anybody know how to make the illegal XML characters show using OOXML in an Excel sheet?</p> <p>EDIT:<br> In function I am using to create a text cell is:</p> <pre><code>private static Cell CreateTextCell(string header, UInt32 index, string text) { var c = new Cell { DataType = CellValues.String, CellReference = header + index }; var cellValue = new CellValue(text); c.Append(cellValue); return c; } </code></pre> <p>I know it has to do with illegal characters because when I didn't include a particular field in my text it worked, then when I included it, Excel would give me a parser error and a blank document.</p> <p>The text that I deal with also happens to have HTML tags in it as well.</p> <p>ps. lol, I just noticed that the markdown used parsed my HTML escape making my example look ridiculous.</p> <p>edit 2:</p> <p>Some example of input:</p> <ul> <li><p>Cancer&apos;s Complexity: Are we Looking at the Wrong Levels to Develop Effective Interventions?</p></li> <li><p>Prospective study of breast cancer risk in mutation-negative women from &lt;i&gt;BRCA1&lt;/i&gt; or &lt;i&gt;BRCA2&lt;/i&gt; mutation-positive families in the Kathleen Cuningham Foundation Consortium for Research into Familial Breast Cancer (kConFab).</p></li> <li><p>Germline &lt;em&gt;BRCA2&lt;/em&gt; mutations correlate with aggressive prostate cancer and adverse outcome.</p></li> </ul> <p>The html formatting is basically so it displays on the web page. I should just strip off the basic formatting tags. But more importantly, I want the excel file to load and escaping the values is a sure way of doing just that.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload