This is a migrated thread and some comments may be shown as answers.

Problem reading pasted values

1 Answer 76 Views
SpreadProcessing
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 09 Feb 2017, 02:20 PM

I'm having a problem reading values from a cell when a certain user is pasting into the spreadsheet and keeping the existing formatting.  When I target the cell and use the GetValue() method I get no result.  When I tore apart the spreadsheet I see that the expected value "Blah Blah Blah" is wrapped in a RichTextRun.  Is there another way that I can drill into the details of this cell to get this value?

<si>
        <r>
            <rPr>
                <sz val="8"/>
                <rFont val="Arial"/>
                <family val="34"/>
            </rPr><t>Blah Blah Blah</t>
        </r>
    </si>

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 14 Feb 2017, 12:02 PM
Hello Josh,

We were not able to reproduce the mentioned issue. I am attaching a test file that contains rich text content in cell E5. After importing this file I have used the following code to get the cell value:
ICellValue value = worksheet.Cells[4, 4].GetValue().Value;
CellValueFormat format = worksheet.Cells[4, 4].GetFormat().Value;
string rawValue = value.RawValue;
string resultValue = value.GetResultValueAsString(format);
Debug.WriteLine("Cell E5 has rich content with raw value <{0}> and result value <{1}>.", rawValue, resultValue);

As a result in the debug output window I get the following line:
Cell E5 has rich content with raw value <cell 3 rich> and result value <cell 3 rich>.

As RadSpreadProcessing currently does not support rich text content, the cell values are provided as plain text only. We have already logged rich text support feature request in our feedback portal and you may vote for it and follow its implementation progress by following this feedback item. In the concrete case of the attached document, cell E5 has rich text content which may be seen by unzipping the XLSX file and opening sharedStrings.xml. This rich text content is defined as follows:
<si>
    <r>
        <t xml:space="preserve">cell </t>
    </r>
    <r>
        <rPr>
            <i/>
            <sz val="11"/>
            <color theme="1"/>
            <rFont val="Calibri"/>
            <family val="2"/>
            <scheme val="minor"/>
        </rPr>
        <t>3</t>
    </r>
    <r>
        <rPr>
            <sz val="11"/>
            <color theme="1"/>
            <rFont val="Calibri"/>
            <family val="2"/>
            <scheme val="minor"/>
        </rPr>
        <t xml:space="preserve"> </t>
    </r>
    <r>
        <rPr>
            <b/>
            <sz val="11"/>
            <color theme="1"/>
            <rFont val="Calibri"/>
            <family val="2"/>
            <scheme val="minor"/>
        </rPr>
        <t>rich</t>
    </r>
</si>

I hope this is helpful. If you still face any issues you may open a support thread and send us the problematic file as the issue may be content specific.

Regards,
Deyan
Telerik by Progress

Tags
SpreadProcessing
Asked by
Josh
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or