컨텍스트는 기본적으로 모든 자식 셀의 데이터를 필터링하고 보고서 레이아웃에도 영향을 미치므로 ReportSheet에서 매우 중요한 개념입니다. 모든 자식 셀에는 컨텍스트 셀이 반복됩니다.
하나의 셀에는 세로와 가로, 두 개의 컨텍스트가 있을 수 있습니다. 세로 컨텍스트와 가로 컨텍스트가 모두 있는 셀은 교차 셀로, 교차 보고서를 생성하는 데 사용할 수 있습니다.
다음 코드를 사용하여 셀의 세로 및 가로 컨텍스트를 설정할 수 있습니다.
// set vertical context as a custom cell
templateSheet.setTemplateCell(1, 1, {
type: 'Group',
binding: `Orders[customerId]`,
context: {
vertical: 'A1',
},
});
// set vertical context as none
templateSheet.setTemplateCell(1, 1, {
type: 'Group',
binding: `Orders[customerId]`,
context: {
vertical: 'None',
},
});
// set horizontal context as a custom cell
templateSheet.setTemplateCell(1, 1, {
type: 'Group',
binding: `Orders[customerId]`,
spillDirection: 'Horizontal',
context: {
horizontal: 'A1',
},
});
// set horizontal context as a custom cell
templateSheet.setTemplateCell(1, 1, {
type: 'Group',
binding: `Orders[customerId]`,
spillDirection: 'Horizontal',
context: {
horizontal: 'None',
},
});
// set both vertical and horizontal context for a cell.
templateSheet.setTemplateCell(1, 1, {
type: 'Summary',
aggregate: 'Sum',
binding: `Sales[Sales]`,
context: {
vertical: 'A2',
horizontal: 'B1',
},
});