public string GetRange(TextRange Range)
{
if (Range.FirstRow >= Count)
Range.FirstRow = Count;
if (Range.LastRow >= Count)
Range.LastRow = Count;
if (Range.FirstRow != Range.LastRow)
{
//note:error has been tracked here
Row r1 = this[Range.FirstRow];
int mx = Math.Min(r1.Text.Length, Range.FirstColumn);
string s1 = r1.Text.Substring(mx) + Environment.NewLine;
//if (Range.LastRow >= this.Count)
// Range.LastRow=this.Count -1;
Row r2 = this[Range.LastRow];
if (r2 == null)
return "";
int Max = Math.Min(r2.Text.Length, Range.LastColumn);
string s2 = r2.Text.Substring(0, Max);
var sb = new StringBuilder();
for (int i = Range.FirstRow + 1; i <= Range.LastRow - 1; i++)
{
Row r3 = this[i];
sb.Append(r3.Text + Environment.NewLine);
}
string s3 = sb.ToString();
return s1 + s3 + s2;
}
else
{
Row r = this[Range.FirstRow];
int Max = Math.Min(r.Text.Length, Range.LastColumn);
int Length = Max - Range.FirstColumn;
if (Length <= 0)
return "";
string s = r.Text.Substring(Range.FirstColumn, Max - Range.FirstColumn);
return s;
}
}