Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Correct 5ded6212-e8d4-4206-9025-cb5991bd2f80.md (Insert text into cell) #20

Merged
merged 2 commits into from
Mar 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions en-us/OpenXMLCon/articles/5ded6212-e8d4-4206-9025-cb5991bd2f80.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,13 @@ The following is the complete sample code in both C# and Visual Basic.
Cell refCell = null;
foreach (Cell cell in row.Elements<Cell>())
{
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
if (cell.CellReference.Value.Length == cellReference.Length)
{
refCell = cell;
break;
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
{
refCell = cell;
break;
}
}
}

Expand Down Expand Up @@ -738,9 +741,11 @@ Private Function InsertCellInWorksheet(ByVal columnName As String, ByVal rowInde
' Cells must be in sequential order according to CellReference. Determine where to insert the new cell.
Dim refCell As Cell = Nothing
For Each cell As Cell In row.Elements(Of Cell)()
If (String.Compare(cell.CellReference.Value, cellReference, True) > 0) Then
refCell = cell
Exit For
If (cell.CellReference.Value.Length == cellReference.Length)
If (String.Compare(cell.CellReference.Value, cellReference, True) > 0) Then
refCell = cell
Exit For
End If
End If
Next

Expand Down