[]
The auto-fit feature in ReportSheet automatically adjusts column width and row height to fit the content when generating reports. For this, you need to configure the autoFit
property in the setTemplateCell
method.
You can set the following enum values for auto-fit operation while working with ReportSheet:
None
Row
Column
The following code sample shows how to set the auto-fit types for the template cell.
// Set the autoFit property as Row.
templateSheet.setTemplateCell(1, 0, {
type: 'List',
binding: Orders[orderDate],
autoFit: 'Row',
});
// Set the autoFit property as Column.
templateSheet.setTemplateCell(1, 2, {
type: 'List',
binding: Orders[shipName],
autoFit: 'Column',
});
// Set the autoFit property as None.
templateSheet.setTemplateCell(1, 3, {
type: 'List',
binding: Orders[shipAddress],
autoFit: 'None',
});
The output of the above code is as follows:
You can also set the autoFit
property of the template cell using the SpreadJS designer's Auto Fit option available in the Report Cell properties panel.
Note:
ReportSheet supports a combination of row and column auto fit within the same report. This means you can apply different auto fit types to different template cells.
AutoFit operations will not reduce row heights or column widths when the autoFit property values are less than the dimensions set in the template.
In the Preview mode, if a cell's autoFit property is set as 'Row' and the cell is part of a row merge, it will expand the last row of the span. Similarly, a cell with 'Column' autofit will expand the last column of the span.