示例#1
0
        void OnInit()
        {
            AddHeaderFooter();

            _excel.VerticalScrollBarVisibility   = ScrollBarVisibility.Hidden;
            _excel.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
            _excel.TabStripVisibility            = Visibility.Collapsed;
            _excel.ShowRowRangeGroup             = false;
            _excel.ShowColumnRangeGroup          = false;

            _sheet.ZoomFactor = 1f;
            ViewportInfo info = new ViewportInfo(_sheet, 1, 1);

            _sheet.SetViewportInfo(info);
            _sheet.ShowGridLine              = _printer.Info.ShowGridLine;
            _sheet.RowHeader.IsVisible       = ShowRowHeader;
            _sheet.ColumnHeader.IsVisible    = ShowColumnHeader;
            _sheet.FrozenRowCount            = 0;
            _sheet.FrozenColumnCount         = 0;
            _sheet.FrozenTrailingRowCount    = 0;
            _sheet.FrozenTrailingColumnCount = 0;
            if (_sheet.RowFilter != null)
            {
                _sheet.RowFilter.ShowFilterButton = false;
            }

            SheetTable[] tables = _sheet.GetTables();
            if (tables != null)
            {
                for (int i = 0; i < tables.Length; i++)
                {
                    tables[i].RowFilter.ShowFilterButton = false;
                }
            }

            if (_printer.Info.BestFitColumns)
            {
                int num2 = (_printer.Info.ColumnStart != -1) ? _printer.Info.ColumnStart : 0;
                int num3 = _printer.Info.UseMax ? _sheet.GetLastDirtyColumn(StorageType.Axis | StorageType.Sparkline | StorageType.Tag | StorageType.Style | StorageType.Data) : (_sheet.ColumnCount - 1);
                int num4 = (_printer.Info.ColumnEnd != -1) ? _printer.Info.ColumnEnd : num3;
                for (int j = num2; j <= num4; j++)
                {
                    _excel.AutoFitColumn(j, false);
                }
                for (int k = 0; k < _sheet.RowHeader.ColumnCount; k++)
                {
                    _excel.AutoFitColumn(k, true);
                }
            }

            if (_printer.Info.BestFitRows)
            {
                int num7 = (_printer.Info.RowStart != -1) ? _printer.Info.RowStart : 0;
                int num8 = _printer.Info.UseMax ? _sheet.GetLastDirtyRow(StorageType.Axis | StorageType.Sparkline | StorageType.Tag | StorageType.Style | StorageType.Data) : (_sheet.RowCount - 1);
                int num9 = (_printer.Info.RowEnd != -1) ? _printer.Info.RowEnd : num8;
                for (int m = num7; m <= num9; m++)
                {
                    _excel.AutoFitRow(m, false);
                }
                for (int n = 0; n < _sheet.ColumnHeader.RowCount; n++)
                {
                    _excel.AutoFitRow(n, true);
                }
            }

            if ((_pageInfo.ColumnPage.RepeatItemStart != -1) && (_pageInfo.ColumnPage.RepeatItemEnd != -1))
            {
                _sheet.FrozenColumnCount = _pageInfo.ColumnPage.RepeatItemEnd + 1;
                for (int num12 = 0; num12 < _pageInfo.ColumnPage.RepeatItemStart; num12++)
                {
                    _sheet.Columns[num12].IsVisible = false;
                }
                _excel.ShowFreezeLine = false;
            }

            if ((_pageInfo.RowPage.RepeatItemStart != -1) && (_pageInfo.RowPage.RepeatItemEnd != -1))
            {
                _sheet.FrozenRowCount = _pageInfo.RowPage.RepeatItemEnd + 1;
                for (int num13 = 0; num13 < _pageInfo.RowPage.RepeatItemStart; num13++)
                {
                    _sheet.Rows[num13].IsVisible = false;
                }
                _excel.ShowFreezeLine = false;
            }

            int itemStart = _pageInfo.ColumnPage.ItemStart;
            int row       = _pageInfo.RowPage.ItemStart;

            if (((itemStart >= 0) && (itemStart < _sheet.ColumnCount)) && ((row >= 0) && (row < _sheet.RowCount)))
            {
                _excel.ShowColumn(0, itemStart, HorizontalPosition.Left);
                _excel.ShowRow(0, row, VerticalPosition.Top);
            }
            Children.Add(_excel);

            if (_printer.Info.ShowBorder)
            {
                _border                 = new Border();
                _border.BorderBrush     = new SolidColorBrush(Colors.Black);
                _border.BorderThickness = new Thickness(1.0);
                Children.Add(_border);
            }
        }