NPOI.XSSF.UserModel.XSSFWorkbook.GetReferenceBuiltInRecord C# (CSharp) Method

GetReferenceBuiltInRecord() private static method

private static GetReferenceBuiltInRecord ( String sheetName, int startC, int endC, int startR, int endR ) : String
sheetName String
startC int
endC int
startR int
endR int
return String
        private static String GetReferenceBuiltInRecord(String sheetName, int startC, int endC, int startR, int endR)
        {
            //windows excel example for built-in title: 'second sheet'!$E:$F,'second sheet'!$2:$3
            CellReference colRef = new CellReference(sheetName, 0, startC, true, true);
            CellReference colRef2 = new CellReference(sheetName, 0, endC, true, true);

            String escapedName = SheetNameFormatter.Format(sheetName);

            String c;
            if (startC == -1 && endC == -1) c = "";
            else c = escapedName + "!$" + colRef.CellRefParts[2] + ":$" + colRef2.CellRefParts[2];

            CellReference rowRef = new CellReference(sheetName, startR, 0, true, true);
            CellReference rowRef2 = new CellReference(sheetName, endR, 0, true, true);

            String r = "";
            if (startR == -1 && endR == -1) r = "";
            else
            {
                if (!rowRef.CellRefParts[1].Equals("0") && !rowRef2.CellRefParts[1].Equals("0"))
                {
                    r = escapedName + "!$" + rowRef.CellRefParts[1] + ":$" + rowRef2.CellRefParts[1];
                }
            }

            StringBuilder rng = new StringBuilder();
            rng.Append(c);
            if (rng.Length > 0 && r.Length > 0) rng.Append(',');
            rng.Append(r);
            return rng.ToString();
        }