private int GetSheetExtIx(SheetIdentifier sheetIden)
        {
            int extIx;

            if (sheetIden == null)
            {
                extIx = -1;
            }
            else
            {
                string workbookName   = sheetIden.BookName;
                string firstSheetName = sheetIden.SheetId.Name;
                string lastSheetName  = firstSheetName;

                if (sheetIden is SheetRangeIdentifier)
                {
                    lastSheetName = ((SheetRangeIdentifier)sheetIden).LastSheetIdentifier.Name;
                }

                if (workbookName == null)
                {
                    int firstSheetIndex = _uBook.GetSheetIndex(firstSheetName);
                    int lastSheetIndex  = _uBook.GetSheetIndex(lastSheetName);
                    extIx = _iBook.checkExternSheet(firstSheetIndex, lastSheetIndex);
                }
                else
                {
                    extIx = _iBook.GetExternalSheetIndex(workbookName, firstSheetName, lastSheetName);
                }
            }
            return(extIx);
        }
        public void SheetIdentifierTest()
        {
            var res = new SheetIdentifier(new DocumentFormat.OpenXml.Spreadsheet.Sheet {
                Id = "1", Name = "test"
            });

            Assert.AreEqual("1", res.Id);
            Assert.AreEqual("test", res.Name);
        }
Exemple #3
0
 public Ptg Get3DReferencePtg(CellReference cell, SheetIdentifier sheet)
 {
     if (sheet._bookName != null)
     {
         int bookIndex = ResolveBookIndex(sheet._bookName);
         return(new Ref3DPxg(bookIndex, sheet, cell));
     }
     else
     {
         return(new Ref3DPxg(sheet, cell));
     }
 }
Exemple #4
0
 public Ptg Get3DReferencePtg(AreaReference area, SheetIdentifier sheet)
 {
     if (sheet._bookName != null)
     {
         int bookIndex = ResolveBookIndex(sheet._bookName);
         return(new Area3DPxg(bookIndex, sheet, area));
     }
     else
     {
         return(new Area3DPxg(sheet, area));
     }
 }
Exemple #5
0
 public Ref3DPxg(int externalWorkbookNumber, SheetIdentifier sheetName, CellReference c)
     : base(c)
 {
     this.externalWorkbookNumber = externalWorkbookNumber;
     this.firstSheetName = sheetName.SheetId.Name;
     if (sheetName is SheetRangeIdentifier)
     {
         this.lastSheetName = ((SheetRangeIdentifier)sheetName).LastSheetIdentifier.Name;
     }
     else
     {
         this.lastSheetName = null;
     }
 }
Exemple #6
0
 public Ref3DPxg(int externalWorkbookNumber, SheetIdentifier sheetName, CellReference c)
     : base(c)
 {
     this.externalWorkbookNumber = externalWorkbookNumber;
     firstSheetName = sheetName.SheetId.Name;
     if (sheetName is SheetRangeIdentifier)
     {
         lastSheetName = ((SheetRangeIdentifier)sheetName).LastSheetIdentifier.Name;
     }
     else
     {
         lastSheetName = null;
     }
 }
Exemple #7
0
 public Area3DPxg(int externalWorkbookNumber, SheetIdentifier sheetName, AreaReference arearef)
     : base(arearef)
 {
     this.externalWorkbookNumber = externalWorkbookNumber;
     this.firstSheetName         = sheetName.SheetId.Name;
     if (sheetName is SheetRangeIdentifier)
     {
         this.lastSheetName = ((SheetRangeIdentifier)sheetName).LastSheetIdentifier.Name;
     }
     else
     {
         this.lastSheetName = null;
     }
 }
Exemple #8
0
        /// <summary>
        /// Return an external name (named range, function, user-defined function) Pxg
        /// </summary>
        /// <param name="name"></param>
        /// <param name="sheet"></param>
        /// <returns></returns>
        public Ptg GetNameXPtg(String name, SheetIdentifier sheet)
        {
            // First, try to find it as a User Defined Function
            IndexedUDFFinder udfFinder = (IndexedUDFFinder)GetUDFFinder();
            FreeRefFunction  func      = udfFinder.FindFunction(name);

            if (func != null)
            {
                return(new NameXPxg(null, name));
            }

            // Otherwise, try it as a named range
            if (sheet == null)
            {
                if (_uBook.GetNames(name).Count > 0)
                {
                    return(new NameXPxg(null, name));
                }
                return(null);
            }
            if (sheet._sheetIdentifier == null)
            {
                // Workbook + Named Range only
                int bookIndex = ResolveBookIndex(sheet._bookName);
                return(new NameXPxg(bookIndex, null, name));
            }

            // Use the sheetname and process
            String sheetName = sheet._sheetIdentifier.Name;

            if (sheet._bookName != null)
            {
                int bookIndex = ResolveBookIndex(sheet._bookName);
                return(new NameXPxg(bookIndex, sheetName, name));
            }
            else
            {
                return(new NameXPxg(sheetName, name));
            }
        }
Exemple #9
0
        IEnumerable <T> readSheet <T>(WorksheetPart wSheet) where T : new()
        {
            Map <T>         map   = getMap <T>(wSheet);
            SheetIdentifier Sheet = createSheetIdentifier(wSheet);

            if (!map.IsValid)
            {
                OnValidationFailure(this, new SheetValidationErrorEventArgs(map.MissingFields, map.Exceptioins, Sheet));
                yield break;
            }

            foreach (Row row in wSheet.Worksheet.Descendants <Row>().Skip(getSkip()))
            {
                T tmp;
                try { tmp = rowToObject <T>(row, map); }
                catch (CellReadingException ex)
                {
                    cellErrorEventCaller(new CellReadingErrorEventArgs
                    {
                        Reference  = ex.Reference,
                        SourceType = ex.SourceType,
                        OutputType = ex.OutputType,
                        Value      = ex.Value,
                        Row        = row.RowIndex.Value,
                        Sheet      = Sheet,
                    });

                    if (_config.ContinueOnRowReadingError)
                    {
                        continue;
                    }
                    else
                    {
                        throw;
                    }
                }
                yield return(tmp);
            }
        }
Exemple #10
0
 public Area3DPxg(int externalWorkbookNumber, SheetIdentifier sheetName, String arearef)
     : this(externalWorkbookNumber, sheetName, new AreaReference(arearef))
 {
     ;
 }
        public Ptg GetNameXPtg(string name, SheetIdentifier sheet)
        {
            int sheetRefIndex = GetSheetExtIx(sheet);

            return(_iBook.GetNameXPtg(name, sheetRefIndex, _uBook.GetUDFFinder()));
        }
Exemple #12
0
        public Area3DPxg(SheetIdentifier sheetName, AreaReference arearef)
            : this(-1, sheetName, arearef)
        {

        }
Exemple #13
0
 public Area3DPxg(SheetIdentifier sheetName, String arearef)
     : this(sheetName, new AreaReference(arearef))
 {
 }
Exemple #14
0
 public Ref3DPxg(SheetIdentifier sheetName, CellReference c)
     : this(-1, sheetName, c)
 {
 }
Exemple #15
0
        public Ref3DPxg(int externalWorkbookNumber, SheetIdentifier sheetName, String cellref)
            : this(externalWorkbookNumber, sheetName, new CellReference(cellref))
        {

        }
Exemple #16
0
 public Ref3DPxg(int externalWorkbookNumber, SheetIdentifier sheetName, String cellref)
     : this(externalWorkbookNumber, sheetName, new CellReference(cellref))
 {
 }
Exemple #17
0
 public Ref3DPxg(SheetIdentifier sheetName, String cellref)
     : this(sheetName, new CellReference(cellref))
 {
 }
Exemple #18
0
        public Ref3DPxg(SheetIdentifier sheetName, String cellref)
            : this(sheetName, new CellReference(cellref))
        {

        }
Exemple #19
0
 public SheetValidationErrorEventArgs(IEnumerable <string> missingFields, IEnumerable <Exception> exceptions, SheetIdentifier sheet)
 {
     MissingFields = missingFields;
     Exceptions    = exceptions;
     Sheet         = sheet;
 }
Exemple #20
0
 public Area3DPxg(int externalWorkbookNumber, SheetIdentifier sheetName, String arearef)
     : this(externalWorkbookNumber, sheetName, new AreaReference(arearef))
 {
     ;
 }
Exemple #21
0
 public Area3DPxg(SheetIdentifier sheetName, String arearef)
     : this(sheetName, new AreaReference(arearef))
 {
 }
        public Ptg Get3DReferencePtg(AreaReference areaRef, SheetIdentifier sheet)
        {
            int extIx = GetSheetExtIx(sheet);

            return(new Area3DPtg(areaRef, extIx));
        }
        public Ptg Get3DReferencePtg(CellReference cr, SheetIdentifier sheet)
        {
            int extIx = GetSheetExtIx(sheet);

            return(new Ref3DPtg(cr, extIx));
        }
Exemple #24
0
        public Ref3DPxg(SheetIdentifier sheetName, CellReference c)
            : this(-1, sheetName, c)
        {

        }
Exemple #25
0
 public Area3DPxg(SheetIdentifier sheetName, AreaReference arearef)
     : this(-1, sheetName, arearef)
 {
 }
        /**
 *
 * @param sheetIden may be <code>null</code>
 * @param part1
 * @param part2 may be <code>null</code>
 */
        private ParseNode CreateAreaRefParseNode(SheetIdentifier sheetIden, SimpleRangePart part1,
                SimpleRangePart part2)
        {

            int extIx;
            if (sheetIden == null)
            {
                extIx = Int32.MinValue;
            }
            else
            {
                String sName = sheetIden.SheetID.Name;
                if (sheetIden.BookName == null)
                {
                    extIx = _book.GetExternalSheetIndex(sName);
                }
                else
                {
                    extIx = _book.GetExternalSheetIndex(sheetIden.BookName, sName);
                }
            }
            Ptg ptg;
            if (part2 == null)
            {
                CellReference cr = part1.getCellReference();
                if (sheetIden == null)
                {
                    ptg = new RefPtg(cr);
                }
                else
                {
                    ptg = new Ref3DPtg(cr, extIx);
                }
            }
            else
            {
                AreaReference areaRef = CreateAreaRef(part1, part2);

                if (sheetIden == null)
                {
                    ptg = new AreaPtg(areaRef);
                }
                else
                {
                    ptg = new Area3DPtg(areaRef, extIx);
                }
            }
            return new ParseNode(ptg);
        }