Skip to content

Commit 6fc355b

Browse files
authored
Merge pull request #452 from syncfusion-content/FLUT-6940-PageSetupXlsIO-Dev
FLUT-6940-PageSetupXlsIO-Dev
2 parents 3a30f03 + 42d8285 commit 6fc355b

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

Flutter/xlsio/working-with-excel-worksheet.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,62 @@ File('Output.xlsx').writeAsBytes(bytes);
116116

117117
{% endhighlight %}
118118

119+
## PageSetup Settings
120+
121+
Excel worksheets can be customized with page setup settings such as orientation, margins, scaling, paper size, print area, gridlines, black and white, draft quality, row and column headings, and page order. The following code snippet shows how to use page setup properties.
122+
123+
{% highlight dart %}
124+
//Create a new Excel Document.
125+
final Workbook workbook = Workbook();
126+
127+
//Accessing sheet via index.
128+
final Worksheet sheet = workbook.worksheets[0];
129+
130+
//Set text
131+
sheet.getRangeByName('A1:Z100').text = 'Hello';
132+
133+
//Center Horizontally and center Vertically
134+
sheet.pageSetup.isCenterHorizontally = true;
135+
sheet.pageSetup.isCenterVertically = true;
136+
137+
//Orientation
138+
sheet.pageSetup.orientation = ExcelPageOrientation.landscape;
139+
140+
//Margins
141+
sheet.pageSetup.topMargin = 1;
142+
sheet.pageSetup.leftMargin = 2;
143+
sheet.pageSetup.rightMargin = 1.25;
144+
sheet.pageSetup.bottomMargin = 1;
145+
sheet.pageSetup.footerMargin = 4;
146+
sheet.pageSetup.headerMargin = 3.5;
147+
148+
//Paper size
149+
sheet.pageSetup.paperSize = ExcelPaperSize.a2Paper;
150+
151+
//Print area
152+
sheet.pageSetup.printArea = 'A1:D20';
153+
154+
//Gridlines
155+
sheet.pageSetup.showGridlines = true;
156+
157+
//Black and white
158+
sheet.pageSetup.isBlackAndWhite = true;
159+
160+
//Draft
161+
sheet.pageSetup.isDraft = true;
162+
163+
//Row and column headings
164+
sheet.pageSetup.showHeadings = true;
165+
166+
//Page order
167+
sheet.pageSetup.order = ExcelPageOrder.overThenDown;
168+
169+
//Save and dispose workbook.
170+
final List<int> bytes = workbook.saveAsStream();
171+
workbook.dispose();
172+
File('Output.xlsx').writeAsBytes(bytes);
173+
{% endhighlight %}
174+
119175
## Show or Hide Worksheet
120176

121177
The following code snippet shows how to hide the worksheet using **visibility** property.

0 commit comments

Comments
 (0)