Exemple #1
0
        private XlsxDimension ReadDimension(XmlReader xmlReader)
        {
            var dimValue = xmlReader.GetAttribute(ARef);

            xmlReader.Skip();

            if (!string.IsNullOrEmpty(dimValue))
            {
                var dimension = new XlsxDimension(dimValue);
                if (dimension.IsRange)
                {
                    return(dimension);
                }
            }

            return(null);
        }
        private void ReadWorksheetGlobals()
        {
            if (string.IsNullOrEmpty(Path))
            {
                return;
            }

            foreach (var sheetObject in ReadWorksheetStream(true))
            {
                switch (sheetObject.Type)
                {
                case XlsxElementType.Dimension:
                    Dimension = (XlsxDimension)sheetObject;
                    break;

                case XlsxElementType.HeaderFooter:
                    XlsxHeaderFooter headerFooter = (XlsxHeaderFooter)sheetObject;
                    HeaderFooter = headerFooter.Value;
                    break;
                }
            }

            if (Dimension == null)
            {
                int rows = int.MinValue;
                int cols = int.MinValue;
                foreach (var sheetObject in ReadWorksheetStream(false))
                {
                    if (sheetObject.Type == XlsxElementType.Row)
                    {
                        var rowBlock = (XlsxRow)sheetObject;
                        rows = Math.Max(rows, rowBlock.RowIndex);
                        cols = Math.Max(cols, rowBlock.GetMaxColumnIndex());
                    }
                }

                if (rows != int.MinValue && cols != int.MinValue)
                {
                    Dimension = new XlsxDimension(rows, cols);
                }
            }
        }