Ejemplo n.º 1
0
        private Worksheet ProcessGetWorksheet(OXWorkbookWorksheetEntry e)
        {
            OXRelation r = _excelRelations.GetRelation(e.RelationId);

            if (r == null)
            {
                throw new Exception(string.Format("Relationship id {0} does not exist in the relationships for worksheet name {1}", e.RelationId, e.Name));
            }

            string subPath = r.Target.Replace('/', '\\');
            string path    = null;

            if (subPath.StartsWith(@"\xl"))
            {
                path = subPath.Substring(1);
            }
            else
            {
                path = @"xl\" + subPath;
            }
            OXWorksheet ows = OXNS.Load <OXWorksheet>(
                _f,
                path
                );

            if (ows == null)
            {
                throw new Exception(string.Format("Worksheet target {0} does not exist for relation id {1}", r.Target, r.Id));
            }

            return(new Worksheet(this, e.Name, ows));
        }
Ejemplo n.º 2
0
        public CellMap(OXWorksheet ws)
        {
            foreach (OXRow r in ws.Rows)
            {
                if (r.Cells == null)
                {
                    continue;
                }

                foreach (OXCell c in r.Cells)
                {
                    uint row = A1Translator.GetRowIndex(c.Reference) - 1;

                    if (!_firstRow.HasValue || row < _firstRow.Value)
                    {
                        _firstRow = row;
                    }

                    if (!_lastRow.HasValue || row > _lastRow.Value)
                    {
                        _lastRow = row;
                    }

                    ColMap cols;

                    if (!_rows.TryGetValue(row, out cols))
                    {
                        _rows.Add(row, cols = new ColMap());
                    }

                    uint col = A1Translator.GetCellIndex(c.Reference) - 1;

                    if (!_firstCol.HasValue || col < _firstCol.Value)
                    {
                        _firstCol = col;
                    }

                    if (!_lastCol.HasValue || col > _lastCol.Value)
                    {
                        _lastCol = col;
                    }

#if DEBUG
                    if (cols.ContainsKey(col))
                    {
                        throw new Exception(string.Format("Duplicate reference {0}", c.Reference));
                    }
#endif

                    if (!cols.ContainsKey(col))
                    {
                        cols.Add(col, c);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        internal Worksheet(Workbook wb, string name, OXWorksheet s)
        {
#if DEBUG
            _cellMap = new CellMap(s);
#endif

            _wb = wb;

            _s = s;

            _name = name;
        }
Ejemplo n.º 4
0
        private Worksheet ProcessGetWorksheet(OXWorkbookWorksheetEntry e)
        {
            OXRelation r = _excelRelations.GetRelation(e.RelationId);

            if (r == null)
            {
                throw new Exception(string.Format("Relationship id {0} does not exist in the relationships for worksheet name {1}", e.RelationId, e.Name));
            }

            OXWorksheet ows = OXNS.Load <OXWorksheet>(
                _f,
                @"xl\" + r.Target.Replace('/', '\\')
                );

            if (ows == null)
            {
                throw new Exception(string.Format("Worksheet target {0} does not exist for relation id {1}", r.Target, r.Id));
            }

            return(new Worksheet(this, e.Name, ows));
        }