Esempio n. 1
0
        private void ReadWorksheetGlobals()
        {
            if (string.IsNullOrEmpty(Path))
            {
                return;
            }

            int rows = int.MinValue;
            int cols = int.MinValue;

            foreach (var sheetObject in ReadWorksheetStream(false))
            {
                if (sheetObject.Type == XlsxElementType.Row)
                {
                    var rowBlock = ((XlsxRow)sheetObject).Row;
                    rows = Math.Max(rows, rowBlock.RowIndex);
                    cols = Math.Max(cols, rowBlock.GetMaxColumnIndex());
                }
                else if (sheetObject.Type == XlsxElementType.HeaderFooter)
                {
                    XlsxHeaderFooter headerFooter = (XlsxHeaderFooter)sheetObject;
                    HeaderFooter = headerFooter.Value;
                }
            }

            if (rows != int.MinValue && cols != int.MinValue)
            {
                FieldCount = cols + 1;
            }
        }
        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);
                }
            }
        }