diff --git a/EPPlus-4.0.3/ExcelCellBase.cs b/EPPlus-4.0.3/ExcelCellBase.cs
--- a/EPPlus-4.0.3/ExcelCellBase.cs
+++ b/EPPlus-4.0.3/ExcelCellBase.cs
@@ -480,17 +480,15 @@
bool fixedRow, fixedCol;
return GetRowCol(address, out row, out col, throwException, out fixedRow, out fixedCol);
}
- internal static bool GetRowCol(string address, out int row, out int col, bool throwException, out bool fixedRow, out bool fixedCol)
- {
+ internal static bool GetRowCol(string address, out int row, out int col, bool throwException, out bool fixedRow, out bool fixedCol) {
bool colPart = true;
- string sRow = "", sCol = "";
+ int colStartIx = 0;
+ int colLength = 0;
col = 0;
+ row = 0;
fixedRow = false;
fixedCol = false;
- if (address.IndexOf(':') > 0) //If it is a mult-cell address use
- {
- address = address.Substring(0, address.IndexOf(':'));
- }
+
if (address.EndsWith("#REF!"))
{
row = 0;
@@ -501,71 +499,56 @@
int sheetMarkerIndex = address.IndexOf('!');
if (sheetMarkerIndex >= 0)
{
- address = address.Substring(sheetMarkerIndex + 1);
+ colStartIx = sheetMarkerIndex + 1;
}
- address = address.ToUpper(CultureInfo.InvariantCulture);
- for (int i = 0; i < address.Length; i++)
+ for (int i = colStartIx; i < address.Length; i++)
{
- if ((address[i] >= 'A' && address[i] <= 'Z') && colPart && sCol.Length <= 3)
+ char c = address[i];
+ if (colPart && ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) && colLength <= 3)
{
- sCol += address[i];
+ col *= 26;
+ col += ((int)c) - 64;
+ colLength++;
}
- else if (address[i] >= '0' && address[i] <= '9')
+ else if (c >= '0' && c <= '9')
{
- sRow += address[i];
+ row *= 10;
+ row += ((int)c) - 48;
colPart = false;
}
- else if (address[i] == '$')
+ else if (c == '$')
{
- if (i == 0)
- fixedCol = true;
- else
+ if (i == colStartIx)
+ {
+ colStartIx++;
+ fixedCol = true;
+ }
+ else
+ {
+ colPart = false;
fixedRow = true;
+ }
+ }
+ else if (c == ':')
+ {
+ break;
}
else
{
+ row = 0;
+ col = 0;
if (throwException)
{
throw (new Exception(string.Format("Invalid Address format {0}", address)));
}
else
{
- row = 0;
- col = 0;
return false;
}
}
}
-
- // Get the column number
- if (sCol != "")
- {
- col = GetColumn(sCol);
- }
- else
- {
- col = 0;
- int.TryParse(sRow, out row);
- return row>0;
- }
- // Get the row number
- if (sRow == "") //Blank, fullRow
- {
- //if (throwException)
- //{
- // throw (new Exception(string.Format("Invalid Address format {0}", address)));
- //}
- //else
- //{
- row = 0;
- return col > 0;
- //}
- }
- else
- {
- return int.TryParse(sRow, out row);
- }
+ return row != 0 || col != 0;
}
private static int GetColumn(string sCol)
diff --git a/EPPlus-4.0.3/ExcelRangeBase.cs b/EPPlus-4.0.3/ExcelRangeBase.cs
--- a/EPPlus-4.0.3/ExcelRangeBase.cs
+++ b/EPPlus-4.0.3/ExcelRangeBase.cs
@@ -58,7 +58,7 @@
///
/// A range of cells
///
- public class ExcelRangeBase : ExcelAddress, IExcelCell, IDisposable, IEnumerable, IEnumerator
+ public class ExcelRangeBase : ExcelAddress, IExcelCell, IEnumerable
{
///
/// Reference to the worksheet
@@ -2757,69 +2757,84 @@
CellsStoreEnumerator