示例#1
0
 public SheetRangeIdentifier(String bookName, NameIdentifier firstSheetIdentifier, NameIdentifier lastSheetIdentifier)
     : base(bookName, firstSheetIdentifier)
 {
     _lastSheetIdentifier = lastSheetIdentifier;
 }
示例#2
0
 public SheetIdentifier(String bookName, NameIdentifier sheetIdentifier)
 {
     _bookName = bookName;
     _sheetIdentifier = sheetIdentifier;
 }
示例#3
0
 public SheetIdentifier(String bookName, NameIdentifier sheetIdentifier)
 {
     _bookName        = bookName;
     _sheetIdentifier = sheetIdentifier;
 }
示例#4
0
        /**
         * Note - caller should reset {@link #_pointer} upon <code>null</code> result
         * @return The sheet name as an identifier <code>null</code> if '!' is not found in the right place
         */
        private SheetIdentifier ParseSheetName()
        {

            String bookName;
            if (look == '[')
            {
                StringBuilder sb = new StringBuilder();
                GetChar();
                while (look != ']')
                {
                    sb.Append(look);
                    GetChar();
                }
                GetChar();
                bookName = sb.ToString();
            }
            else
            {
                bookName = null;
            }

            if (look == '\'')
            {
                StringBuilder sb = new StringBuilder();

                Match('\'');
                bool done = look == '\'';
                while (!done)
                {
                    sb.Append(look);
                    GetChar();
                    if (look == '\'')
                    {
                        Match('\'');
                        done = look != '\'';
                    }
                }

                NameIdentifier iden = new NameIdentifier(sb.ToString(), true);
                // quoted identifier - can't concatenate anything more
                SkipWhite();
                if (look == '!')
                {
                    GetChar();
                    return new SheetIdentifier(bookName, iden);
                }
                // See if it's a multi-sheet range, eg Sheet1:Sheet3!A1
                if (look == ':')
                {
                    return ParseSheetRange(bookName, iden);
                }
                return null;
            }

            // unquoted sheet names must start with underscore or a letter
            if (look == '_' || Char.IsLetter(look))
            {
                StringBuilder sb = new StringBuilder();
                // can concatenate idens with dots
                while (IsUnquotedSheetNameChar(look))
                {
                    sb.Append(look);
                    GetChar();
                }
                NameIdentifier iden = new NameIdentifier(sb.ToString(), false);
                SkipWhite();
                if (look == '!')
                {
                    GetChar();
                    return new SheetIdentifier(bookName, iden);
                }
                // See if it's a multi-sheet range, eg Sheet1:Sheet3!A1
                if (look == ':')
                {
                    return ParseSheetRange(bookName, iden);
                }
                return null;
            }

            if (look == '!' && bookName != null)
            {
                // Raw book reference, without a sheet
                GetChar();
                return new SheetIdentifier(bookName, null);
            }
            return null;
        }
示例#5
0
 /**
  * If we have something that looks like [book]Sheet1: or 
  *  Sheet1, see if it's actually a range eg Sheet1:Sheet2!
  */
 private SheetIdentifier ParseSheetRange(String bookname, NameIdentifier sheet1Name)
 {
     GetChar();
     SheetIdentifier sheet2 = ParseSheetName();
     if (sheet2 != null)
     {
         return new SheetRangeIdentifier(bookname, sheet1Name, sheet2._sheetIdentifier);
     }
     return null;
 }
示例#6
0
 public SheetRangeIdentifier(String bookName, NameIdentifier firstSheetIdentifier, NameIdentifier lastSheetIdentifier)
     : base(bookName, firstSheetIdentifier)
 {
     _lastSheetIdentifier = lastSheetIdentifier;
 }