Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed an issue with Range.Text property handling [] incorrectly in some cases
  • Loading branch information
EPPlus committed Nov 29, 2018
1 parent 8097896 commit d3c0492
Show file tree
Hide file tree
Showing 13 changed files with 1,807 additions and 2,989 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public Double Value
|| (Type == eExcelConditionalFormattingValueObjectType.Percent)
|| (Type == eExcelConditionalFormattingValueObjectType.Percentile))
{
valueToStore = value.ToString();
valueToStore = value.ToString(CultureInfo.InvariantCulture);
}

CreateNodeByOrdem(
Expand Down
1 change: 1 addition & 0 deletions EPPlus/Drawing/ExcelDrawingBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ internal static ExcelDrawing GetDrawing(ExcelDrawings drawings, XmlNode node)
{
return new ExcelShape(drawings, node);
}
//}
else if (node.SelectSingleNode("xdr:pic", drawings.NameSpaceManager) != null)
{
return new ExcelPicture(drawings, node);
Expand Down
4 changes: 0 additions & 4 deletions EPPlus/Drawing/Vml/ExcelVmlDrawingComment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ public string Address
{
return Range.Address;
}
internal set
{
Range.Address = value;
}
}

const string VERTICAL_ALIGNMENT_PATH="x:ClientData/x:TextVAlign";
Expand Down
3 changes: 0 additions & 3 deletions EPPlus/EPPlus.MultiTarget.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ Release Candidate changes
</PropertyGroup>

<ItemGroup>
<Compile Remove="Compatibility\DateTimeExtensions.cs" />
<Compile Remove="Compatibility\SecurityElement.cs" />
<Compile Remove="Packaging\DotNetZip\ZipFile.SaveSelfExtractor.cs" />
<Compile Remove="Style\ExcelRichTextHtmlUtility.cs" />
</ItemGroup>


Expand Down
60 changes: 37 additions & 23 deletions EPPlus/ExcelCellBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ internal static ulong GetCellID(int SheetID, int row, int col)
}
#endregion
#region "Formula Functions"
private delegate string dlgTransl(string part, int row, int col, int rowIncr, int colIncr);
private delegate string dlgTransl(string part, int row, int col);
#region R1C1 Functions"
/// <summary>
/// Translates a R1C1 to an absolut address/Formula
Expand All @@ -84,7 +84,7 @@ internal static ulong GetCellID(int SheetID, int row, int col)
/// <returns>The RC address</returns>
public static string TranslateFromR1C1(string value, int row, int col)
{
return Translate(value, ToAbs, row, col, -1, -1);
return Translate(value, ToAbs, row, col);
}
/// <summary>
/// Translates a absolut address to R1C1 Format
Expand All @@ -95,7 +95,7 @@ public static string TranslateFromR1C1(string value, int row, int col)
/// <returns>The absolut address/Formula</returns>
public static string TranslateToR1C1(string value, int row, int col)
{
return Translate(value, ToR1C1, row, col, -1, -1);
return Translate(value, ToR1C1, row, col);
}
/// <summary>
/// Translates betweein R1C1 or absolut addresses
Expand All @@ -104,10 +104,8 @@ public static string TranslateToR1C1(string value, int row, int col)
/// <param name="addressTranslator">The translating function</param>
/// <param name="row"></param>
/// <param name="col"></param>
/// <param name="rowIncr"></param>
/// <param name="colIncr"></param>
/// <returns></returns>
private static string Translate(string value, dlgTransl addressTranslator, int row, int col, int rowIncr, int colIncr)
private static string Translate(string value, dlgTransl addressTranslator, int row, int col)
{
if (value == "")
return "";
Expand All @@ -119,7 +117,7 @@ private static string Translate(string value, dlgTransl addressTranslator, int r
//Console.WriteLine($"{token.TokenType} : {token.Value}");
if (token.TokenType == TokenType.ExcelAddress || token.TokenType.Equals(TokenType.NameValue) || token.TokenType == TokenType.ExcelAddressR1C1)
{
var part = addressTranslator(token.Value, row, col, rowIncr, colIncr);
var part = addressTranslator(token.Value, row, col);
//Console.Write($"==> " + part);
token.Value = part;
}
Expand All @@ -137,7 +135,7 @@ private static string Translate(string value, dlgTransl addressTranslator, int r
/// <param name="rowIncr"></param>
/// <param name="colIncr"></param>
/// <returns></returns>
private static string ToR1C1(string part, int row, int col, int rowIncr, int colIncr)
private static string ToR1C1(string part, int row, int col)
{
int shInd = part.IndexOf('!');
string sh = "";
Expand All @@ -149,17 +147,17 @@ private static string ToR1C1(string part, int row, int col, int rowIncr, int col
int delim = part.IndexOf(':');
if (delim > 0)
{
string p1 = ToR1C1_1(part.Substring(0, delim), row, col, rowIncr, colIncr);
string p2 = ToR1C1_1(part.Substring(delim + 1), row, col, rowIncr, colIncr);
string p1 = ToR1C1_1(part.Substring(0, delim), row, col);
string p2 = ToR1C1_1(part.Substring(delim + 1), row, col);
if (p1.Equals(p2))
return p1;
return sh + p1 + ":" + p2;
}

else
return sh + ToR1C1_1(part, row, col, rowIncr, colIncr);
return sh + ToR1C1_1(part, row, col);
}
private static string ToR1C1_1(string part, int row, int col, int rowIncr, int colIncr)
private static string ToR1C1_1(string part, int row, int col)
{
int addrRow, addrCol;
bool fixRow, fixCol;
Expand Down Expand Up @@ -195,7 +193,7 @@ private static string ToR1C1_1(string part, int row, int col, int rowIncr, int c
/// <param name="rowIncr"></param>
/// <param name="colIncr"></param>
/// <returns></returns>
private static string ToAbs(string part, int row, int col, int rowIncr, int colIncr)
private static string ToAbs(string part, int row, int col)
{
int shInd = part.IndexOf('!');
string sh = "";
Expand All @@ -208,16 +206,16 @@ private static string ToAbs(string part, int row, int col, int rowIncr, int colI
int delim = part.IndexOf(':');
if (delim > 0)
{
string p1 = ToAbs_1(part.Substring(0, delim), row, col, rowIncr, colIncr);
string p2 = ToAbs_1(part.Substring(delim + 1), row, col, rowIncr, colIncr);
string p1 = ToAbs_1(part.Substring(0, delim), row, col, false);
string p2 = ToAbs_1(part.Substring(delim + 1), row, col, false);
if (p1.Equals(p2))
return p1;
return sh + p1 + ":" + p2;
}
else
return sh + ToAbs_1(part, row, col, rowIncr, colIncr);
return sh + ToAbs_1(part, row, col, true);
}
private static string ToAbs_1(string part, int row, int col, int rowIncr, int colIncr)
private static string ToAbs_1(string part, int row, int col, bool isSingle)
{
string check = Utils.ConvertUtil._invariantTextInfo.ToUpper(part);
// Bug
Expand Down Expand Up @@ -248,7 +246,15 @@ private static string ToAbs_1(string part, int row, int col, int rowIncr, int co
int RNum = GetRC(part.Substring(1), row, out absoluteRow);
if (RNum > int.MinValue)
{
return GetAddressRow(RNum, absoluteRow);
var r=GetAddressRow(RNum, absoluteRow);
if (isSingle)
{
return $"{r}:{r}";
}
else
{
return $"{r}";
}
}
else
{
Expand All @@ -260,7 +266,15 @@ private static string ToAbs_1(string part, int row, int col, int rowIncr, int co
int CNum = GetRC(part.Substring(1), col, out absoluteCol);
if (CNum > int.MinValue)
{
return GetAddressCol(CNum, absoluteCol);
var c=GetAddressCol(CNum, absoluteCol);
if (isSingle)
{
return $"{c}:{c}";
}
else
{
return $"{c}";
}
}
else
{
Expand Down Expand Up @@ -612,15 +626,15 @@ private static int GetColumn(string sCol)
public static string GetAddressRow(int Row, bool Absolute = false)
{
if (Absolute)
return $"${Row}:${Row}";
return $"{Row}:{Row}";
return $"${Row}";
return $"{Row}";
}
public static string GetAddressCol(int Col, bool Absolute = false)
{
var colLetter = GetColumnLetter(Col);
if (Absolute)
return $"${colLetter}:${colLetter}";
return $"{colLetter}:{colLetter}";
return $"${colLetter}";
return $"{colLetter}";
}
/// <summary>
/// Returns the AlphaNumeric representation that Excel expects for a Cell Address
Expand Down
Loading

0 comments on commit d3c0492

Please sign in to comment.