Skip to content

Revert "Row pinning + export to excel" #7069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,6 @@ describe('Excel Exporter', () => {
await wrapper.verifyDataFilesContent(actualData.gridJobTitleIdFrozen, 'Not all pinned columns are frozen in the export!');
});

it('should honor all pinned rows.', async() => {
const result = await TestMethods.createGridAndPinRow(0, 2);
const fix = result.fixture;
const grid = result.grid;

const wrapper = await getExportedData(grid, options);
wrapper.verifyStructure();
await wrapper.verifyPinRowData('<pane ySplit="3" topLeftCell="A4" activePane="topRight" state="frozen"/>',
'Not all pinned rows are frozen in the export!');
});

it('should honor applied sorting.', async () => {
const fix = TestBed.createComponent(GridIDNameJobTitleComponent);
fix.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ export class IgxExcelExporterService extends IgxBaseExporter {
}
}

const worksheetData = new WorksheetData(data, options, this._indexOfLastPinnedColumn,
this._indexOfLastPinnedRow, this._sort, this._isTreeGrid);
const worksheetData = new WorksheetData(data, options, this._indexOfLastPinnedColumn, this._sort, this._isTreeGrid);
this._xlsx = new JSZip();

const rootFolder = ExcelElementsFactory.getExcelFolder(ExcelFolderTypes.RootExcelFolder);
Expand Down
23 changes: 6 additions & 17 deletions projects/igniteui-angular/src/lib/services/excel/excel-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,12 @@ export class WorksheetFile implements IExcelFile {

cols.push('</cols>');

const hasFrozenElements = !worksheetData.options.ignorePinning &&
(worksheetData.indexOfLastPinnedColumn !== -1 || worksheetData.indexOfLastPinnedRow !== -1);

if (hasFrozenElements) {
const hasFrozenCols = !worksheetData.options.ignoreColumnsOrder && worksheetData.indexOfLastPinnedColumn !== -1;
const hasFrozenRows = worksheetData.indexOfLastPinnedRow !== -1;

const frozenColumnCount = hasFrozenCols ? worksheetData.indexOfLastPinnedColumn + 1 : null;
const frozenRowCount = hasFrozenRows ? worksheetData.indexOfLastPinnedRow + 2 : null;

const frozenColumn = !hasFrozenCols ? 'A' : ExcelStrings.getExcelColumn(frozenColumnCount);
const firstCell = frozenColumn + (frozenRowCount + 1);

const xSplit = hasFrozenCols ? `xSplit="${frozenColumnCount}" ` : '';
const ySplit = hasFrozenRows ? `ySplit="${frozenRowCount}" ` : '';
const xySplit = (xSplit + ySplit).trim();
freezePane = `<pane ${xySplit} topLeftCell="${firstCell}" activePane="topRight" state="frozen"/>`;
if (worksheetData.indexOfLastPinnedColumn !== -1 &&
!worksheetData.options.ignorePinning &&
!worksheetData.options.ignoreColumnsOrder) {
const frozenColumnCount = worksheetData.indexOfLastPinnedColumn + 1;
const firstCell = ExcelStrings.getExcelColumn(frozenColumnCount) + '1';
freezePane = `<pane xSplit="${frozenColumnCount}" topLeftCell="${firstCell}" activePane="topRight" state="frozen"/>`;
}
}
const hasTable = !worksheetData.isEmpty && worksheetData.options.exportAsTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,6 @@ export class JSZipWrapper {
});
}

public async verifyPinRowData(pinData: string, message = '') {
let result;
await this.readDataFiles().then(() => {
result = this.dataFilesContent[1];
expect(result.fileContent.indexOf(pinData) !== -1).toBeTruthy(message);
});
}

/* Verifies the contents of all files and asserts the result.
Optionally, a message can be passed in, which, if specified, will be shown in the beginning of the comparison result. */
public async verifyFilesContent(expectedData: IFileContent[], message = '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class WorksheetData {
private _isSpecialData: boolean;

constructor(private _data: any[], public options: IgxExcelExporterOptions, public indexOfLastPinnedColumn,
public indexOfLastPinnedRow, public sort: any, public isTreeGridData = false) {
public sort: any, public isTreeGridData = false) {
this.initializeData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export abstract class IgxBaseExporter {

protected _isTreeGrid = false;
protected _indexOfLastPinnedColumn = -1;
protected _indexOfLastPinnedRow = -1;
protected _sort = null;

/**
Expand Down Expand Up @@ -290,14 +289,6 @@ export abstract class IgxBaseExporter {
}
}

if (grid.hasPinnedRecords) {

const pinnedRecs = data.filter(x => grid.isRecordPinned(x));
const unpinnedRecs = data.filter(x => !grid.isRecordPinned(x));
data = [ ...pinnedRecs, ... unpinnedRecs];
this._indexOfLastPinnedRow = pinnedRecs.length - 1;
}

return data;
}

Expand All @@ -316,7 +307,6 @@ export abstract class IgxBaseExporter {
private resetDefaults() {
this._columnList = [];
this._indexOfLastPinnedColumn = -1;
this._indexOfLastPinnedRow = -1;
this._sort = null;
this.flatRecords = [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,4 @@ export class TestMethods {
return { fixture: fix, grid: myGrid };
}


/* Creates an instance of GridDeclarationComponent and pins the rows with the specified indices. */
public static async createGridAndPinRow(...rowIndices: any[]) {
const fix = TestBed.createComponent(GridIDNameJobTitleComponent);
fix.detectChanges();
await wait(16);

const myGrid = fix.componentInstance.grid;

// Pin columns
rowIndices.forEach((i) => {
myGrid.getRowByIndex(i).pin();
});

return { fixture: fix, grid: myGrid };
}

}