You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.
The sample implementation for GetCellValue does not handle formulas correctly. Strictly speaking, it is mishandling "values" (due the implementation of InnerText providing the concat of all inner text).
The issue occurs with the following steps (Using Office 2003):
Put any text into cell A1 (e.g. "exampletext")
Enter into cell A2 "=A1" (with out quotes)
Save, then run the sample code on the workbook and retrieve the value for A2
The above scenario will create sheet data as follows (formatted for readability, only relevant sections included)
(The above sheetdata A1 references the shared string table with index 0, which will result in the string "exampletext")
The problem occurs on the following line of code.
value=theCell.InnerText;// value is "A1exampletext" instead of just "exampletext" or "A1"
Instead, the sample should really reference the value or formula directly
if(theCell.CellValue!=null)value=theCell.CellValue.Text;elseif(theCell.CellFormula!=null)value=theCell.CellFormula.Text;elsevalue=theCell.InnerText;//only use this as a final fallback if all else fails
Alas my understanding of the Open xml spec is limited and I'm unsure of what other potential issues could occur due to the implementation of InnerText (e.g. inner string + value?)
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In the following article:
https://github.com/OfficeDev/office-content/blob/master/en-us/OpenXMLCon/articles/15e26fbd-fc23-466a-a7cc-b7584ba8f821.md
The sample implementation for GetCellValue does not handle formulas correctly. Strictly speaking, it is mishandling "values" (due the implementation of InnerText providing the concat of all inner text).
The issue occurs with the following steps (Using Office 2003):
The above scenario will create sheet data as follows (formatted for readability, only relevant sections included)
(The above sheetdata A1 references the shared string table with index 0, which will result in the string "exampletext")
The problem occurs on the following line of code.
Instead, the sample should really reference the value or formula directly
Alas my understanding of the Open xml spec is limited and I'm unsure of what other potential issues could occur due to the implementation of InnerText (e.g. inner string + value?)
The text was updated successfully, but these errors were encountered: