How to set the printing to fit the page in Spreadsheet?
This article explains how to set the printing to fit the page in JavaScript Spreadsheet. You can export the PDF file that get fitted into a single page by setting pdfLayoutSettings.fitSheetOnOnePage as true in beforeSave event args. Using the below code, you can achieve this requirement.
[HTML]
<div id="spreadsheet"></div>
[TS]
//Initialize Spreadsheet component let spreadsheet: Spreadsheet = new Spreadsheet({ sheets: [ { name: 'Car Sales Report', ranges: [{ dataSource: (dataSource as any).defaultData }], columns: [ { width: 180 }, { width: 130 }, { width: 130 }, { width: 180 }, { width: 130 }, { width: 120 }, { width: 130 }, ], }, ], created: (): void => { //Applies cell and number formatting to specified range of the active sheet spreadsheet.cellFormat( { fontWeight: 'bold', textAlign: 'center', verticalAlign: 'middle' }, 'A1:G1' ); spreadsheet.numberFormat('$#,##0.00', 'F2:F31'); }, beforeSave(args) { args.pdfLayoutSettings.fitSheetOnOnePage = true; // to export pdf in single page } }); //Render initialized Spreadsheet component spreadsheet.appendTo('#spreadsheet');
Sample Link: https://stackblitz.com/edit/yf5mla?file=index.ts
Output:
Documentation:
https://ej2.syncfusion.com/documentation/spreadsheet/open-save/
Conclusion
We hope you enjoyed learning about how to set the printing to fit the page in Spreadsheet.
You can refer to our JavaScript Spreadsheet page to learn about its other groundbreaking feature representations. You can also explore our JavaScript Spreadsheet Documentation to understand how to manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!