• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-angular / 13331632524

14 Feb 2025 02:51PM CUT coverage: 22.015% (-69.6%) from 91.622%
13331632524

Pull #15372

github

web-flow
Merge d52d57714 into bcb78ae0a
Pull Request #15372: chore(*): test ci passing

1990 of 15592 branches covered (12.76%)

431 of 964 new or added lines in 18 files covered. (44.71%)

19956 existing lines in 307 files now uncovered.

6452 of 29307 relevant lines covered (22.02%)

249.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/projects/igniteui-angular/src/lib/services/excel/worksheet-data.ts
1
import { ExportHeaderType, ExportRecordType, IColumnList, IExportRecord } from '../exporter-common/base-export-service';
2
import { ExportUtilities } from '../exporter-common/export-utilities';
3
import { IgxExcelExporterOptions } from './excel-exporter-options';
4
import { WorksheetDataDictionary } from './worksheet-data-dictionary';
5

6
/** @hidden */
7
export class WorksheetData {
8
    private _rowCount: number;
9
    private _dataDictionary: WorksheetDataDictionary;
10
    private _isSpecialData: boolean;
11
    private _hasMultiColumnHeader: boolean;
12
    private _hasMultiRowHeader: boolean;
13
    private _isHierarchical: boolean;
14
    private _hasSummaries: boolean;
15
    private _isPivotGrid: boolean;
16
    private _isTreeGrid: boolean;
17
    private _isGroupedGrid: boolean;
18

UNCOV
19
    constructor(private _data: IExportRecord[],
×
UNCOV
20
                public options: IgxExcelExporterOptions,
×
UNCOV
21
                public sort: any,
×
UNCOV
22
                public columnCount: number,
×
UNCOV
23
                public rootKeys: string[],
×
UNCOV
24
                public indexOfLastPinnedColumn: number,
×
UNCOV
25
                public columnWidths: number[],
×
UNCOV
26
                public owner: IColumnList,
×
UNCOV
27
                public owners: Map<any, IColumnList>) {
×
UNCOV
28
            this.initializeData();
×
29
    }
30

31
    public get data(): IExportRecord[] {
UNCOV
32
        return this._data;
×
33
    }
34

35
    public get rowCount(): number {
UNCOV
36
        return this._rowCount;
×
37
    }
38

39
    public get isEmpty(): boolean {
UNCOV
40
        return !this.rowCount
×
41
            || this.rowCount === this.owner.maxLevel + 1
42
            || !this.columnCount
UNCOV
43
            || this.owner.columns.every(c => c.skip);
×
44
    }
45

46
    public get isSpecialData(): boolean {
UNCOV
47
        return this._isSpecialData;
×
48
    }
49

50
    public get dataDictionary(): WorksheetDataDictionary {
UNCOV
51
        return this._dataDictionary;
×
52
    }
53

54
    public get hasMultiColumnHeader(): boolean {
UNCOV
55
        return this._hasMultiColumnHeader;
×
56
    }
57

58
    public get hasSummaries(): boolean {
UNCOV
59
        return this._hasSummaries;
×
60
    }
61

62
    public get hasMultiRowHeader(): boolean {
UNCOV
63
        return this._hasMultiRowHeader;
×
64
    }
65

66
    public get isHierarchical(): boolean {
UNCOV
67
        return this._isHierarchical;
×
68
    }
69

70
    public get isTreeGrid(): boolean {
UNCOV
71
        return this._isTreeGrid;
×
72
    }
73

74
    public get isPivotGrid(): boolean {
UNCOV
75
        return this._isPivotGrid;
×
76
    }
77

78
    public get isGroupedGrid(): boolean {
UNCOV
79
        return this._data.some(d => d.type === ExportRecordType.GroupedRecord);
×
80
    }
81

82
    public get maxLevel(): number {
UNCOV
83
        return [...new Set(this._data.map(item => item.level))].sort((a,b) => (a > b ? -1 : 1))[0];
×
84
    }
85

86
    public get multiColumnHeaderRows(): number {
UNCOV
87
        return !this.options.ignoreMultiColumnHeaders ? Array.from(this.owners.values()).map(c => c.maxLevel).reduce((a,b) => a + b) : 0;
×
88
    }
89

90
    private initializeData() {
UNCOV
91
        this._dataDictionary = new WorksheetDataDictionary(this.columnCount, this.options.columnWidth, this.columnWidths);
×
92

UNCOV
93
        this._hasMultiColumnHeader = Array.from(this.owners.values())
×
UNCOV
94
            .some(o => o.columns.some(col => !col.skip && col.headerType === ExportHeaderType.MultiColumnHeader));
×
95

UNCOV
96
        this._hasMultiRowHeader = Array.from(this.owners.values())
×
UNCOV
97
            .some(o => o.columns.some(col => !col.skip && col.headerType === ExportHeaderType.MultiRowHeader));
×
98

UNCOV
99
        this._isHierarchical = this.data[0]?.type === ExportRecordType.HierarchicalGridRecord
×
100
            || !(typeof(Array.from(this.owners.keys())[0]) === 'string');
101

UNCOV
102
        this._hasSummaries = this._data.filter(d => d.type === ExportRecordType.SummaryRecord).length > 0;
×
103

UNCOV
104
        this._isTreeGrid = this._data.filter(d => d.type === ExportRecordType.TreeGridRecord).length > 0;
×
105

UNCOV
106
        this._isPivotGrid = this.data[0]?.type === ExportRecordType.PivotGridRecord;
×
107

UNCOV
108
        const exportMultiColumnHeaders = this._hasMultiColumnHeader && !this.options.ignoreMultiColumnHeaders;
×
109

UNCOV
110
        if (this._isHierarchical || exportMultiColumnHeaders || this._isPivotGrid) {
×
UNCOV
111
            this.options.exportAsTable = false;
×
112
        }
113

UNCOV
114
        if (!this._data || this._data.length === 0) {
×
UNCOV
115
            if (!this._isHierarchical) {
×
UNCOV
116
                this._rowCount = this.owner.maxLevel + 1;
×
117
            }
118

UNCOV
119
            return;
×
120
        }
121

UNCOV
122
        this._isSpecialData = ExportUtilities.isSpecialData(this._data[0].data);
×
UNCOV
123
        this._rowCount = this._data.length + this.multiColumnHeaderRows + 1;
×
124
    }
125
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc