Repository navigation
Expand file tree
/
Copy pathpage_setup.html
More file actions
1030 lines (986 loc) · 50.9 KB
/
Copy pathpage_setup.html
File metadata and controls
1030 lines (986 loc) · 50.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The Worksheet Class (Page Setup) — XlsxWriter Documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.3.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="XlsxWriter Documentation" href="index.html" />
<link rel="next" title="The Format Class" href="format.html" />
<link rel="prev" title="The Worksheet Class" href="worksheet.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="format.html" title="The Format Class"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="worksheet.html" title="The Worksheet Class"
accesskey="P">previous</a> |</li>
<li><a href="index.html">XlsxWriter Documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="the-worksheet-class-page-setup">
<span id="page-setup"></span><h1>The Worksheet Class (Page Setup)</h1>
<p>Page set-up methods affect the way that a worksheet looks when it is printed.
They control features such as paper size, orientation, page headers and
margins.</p>
<p>These methods are really just standard <a class="reference internal" href="worksheet.html#worksheet"><em>worksheet</em></a> methods.
They are documented separately for the sake of clarity.</p>
<div class="section" id="worksheet-set-landscape">
<h2>worksheet.set_landscape()</h2>
<dl class="function">
<dt id="set_landscape">
<tt class="descname">set_landscape</tt><big>(</big><big>)</big></dt>
<dd><p>Set the page orientation as landscape.</p>
</dd></dl>
<p>This method is used to set the orientation of a worksheet’s printed page to
landscape:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet</span><span class="o">.</span><span class="n">set_landscape</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="worksheet-set-portrait">
<h2>worksheet.set_portrait()</h2>
<dl class="function">
<dt id="set_portrait">
<tt class="descname">set_portrait</tt><big>(</big><big>)</big></dt>
<dd><p>Set the page orientation as portrait.</p>
</dd></dl>
<p>This method is used to set the orientation of a worksheet’s printed page to
portrait. The default worksheet orientation is portrait, so you won’t
generally need to call this method:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet</span><span class="o">.</span><span class="n">set_portrait</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="worksheet-set-page-view">
<h2>worksheet.set_page_view()</h2>
<dl class="function">
<dt id="set_page_view">
<tt class="descname">set_page_view</tt><big>(</big><big>)</big></dt>
<dd><p>Set the page view mode.</p>
</dd></dl>
<p>This method is used to display the worksheet in “Page View/Layout” mode:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet</span><span class="o">.</span><span class="n">set_page_view</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="worksheet-set-paper">
<h2>worksheet.set_paper()</h2>
<dl class="function">
<dt id="set_paper">
<tt class="descname">set_paper</tt><big>(</big><em>index</em><big>)</big></dt>
<dd><p>Set the paper type.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>index</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a>) – The Excel paper format index.</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>This method is used to set the paper format for the printed output of a
worksheet. The following paper styles are available:</p>
<blockquote>
<div><table border="1" class="docutils">
<colgroup>
<col width="12%" />
<col width="48%" />
<col width="40%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Index</th>
<th class="head">Paper format</th>
<th class="head">Paper size</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>0</td>
<td>Printer default</td>
<td> </td>
</tr>
<tr class="row-odd"><td>1</td>
<td>Letter</td>
<td>8 1/2 x 11 in</td>
</tr>
<tr class="row-even"><td>2</td>
<td>Letter Small</td>
<td>8 1/2 x 11 in</td>
</tr>
<tr class="row-odd"><td>3</td>
<td>Tabloid</td>
<td>11 x 17 in</td>
</tr>
<tr class="row-even"><td>4</td>
<td>Ledger</td>
<td>17 x 11 in</td>
</tr>
<tr class="row-odd"><td>5</td>
<td>Legal</td>
<td>8 1/2 x 14 in</td>
</tr>
<tr class="row-even"><td>6</td>
<td>Statement</td>
<td>5 1/2 x 8 1/2 in</td>
</tr>
<tr class="row-odd"><td>7</td>
<td>Executive</td>
<td>7 1/4 x 10 1/2 in</td>
</tr>
<tr class="row-even"><td>8</td>
<td>A3</td>
<td>297 x 420 mm</td>
</tr>
<tr class="row-odd"><td>9</td>
<td>A4</td>
<td>210 x 297 mm</td>
</tr>
<tr class="row-even"><td>10</td>
<td>A4 Small</td>
<td>210 x 297 mm</td>
</tr>
<tr class="row-odd"><td>11</td>
<td>A5</td>
<td>148 x 210 mm</td>
</tr>
<tr class="row-even"><td>12</td>
<td>B4</td>
<td>250 x 354 mm</td>
</tr>
<tr class="row-odd"><td>13</td>
<td>B5</td>
<td>182 x 257 mm</td>
</tr>
<tr class="row-even"><td>14</td>
<td>Folio</td>
<td>8 1/2 x 13 in</td>
</tr>
<tr class="row-odd"><td>15</td>
<td>Quarto</td>
<td>215 x 275 mm</td>
</tr>
<tr class="row-even"><td>16</td>
<td> </td>
<td>10x14 in</td>
</tr>
<tr class="row-odd"><td>17</td>
<td> </td>
<td>11x17 in</td>
</tr>
<tr class="row-even"><td>18</td>
<td>Note</td>
<td>8 1/2 x 11 in</td>
</tr>
<tr class="row-odd"><td>19</td>
<td>Envelope 9</td>
<td>3 7/8 x 8 7/8</td>
</tr>
<tr class="row-even"><td>20</td>
<td>Envelope 10</td>
<td>4 1/8 x 9 1/2</td>
</tr>
<tr class="row-odd"><td>21</td>
<td>Envelope 11</td>
<td>4 1/2 x 10 3/8</td>
</tr>
<tr class="row-even"><td>22</td>
<td>Envelope 12</td>
<td>4 3/4 x 11</td>
</tr>
<tr class="row-odd"><td>23</td>
<td>Envelope 14</td>
<td>5 x 11 1/2</td>
</tr>
<tr class="row-even"><td>24</td>
<td>C size sheet</td>
<td> </td>
</tr>
<tr class="row-odd"><td>25</td>
<td>D size sheet</td>
<td> </td>
</tr>
<tr class="row-even"><td>26</td>
<td>E size sheet</td>
<td> </td>
</tr>
<tr class="row-odd"><td>27</td>
<td>Envelope DL</td>
<td>110 x 220 mm</td>
</tr>
<tr class="row-even"><td>28</td>
<td>Envelope C3</td>
<td>324 x 458 mm</td>
</tr>
<tr class="row-odd"><td>29</td>
<td>Envelope C4</td>
<td>229 x 324 mm</td>
</tr>
<tr class="row-even"><td>30</td>
<td>Envelope C5</td>
<td>162 x 229 mm</td>
</tr>
<tr class="row-odd"><td>31</td>
<td>Envelope C6</td>
<td>114 x 162 mm</td>
</tr>
<tr class="row-even"><td>32</td>
<td>Envelope C65</td>
<td>114 x 229 mm</td>
</tr>
<tr class="row-odd"><td>33</td>
<td>Envelope B4</td>
<td>250 x 353 mm</td>
</tr>
<tr class="row-even"><td>34</td>
<td>Envelope B5</td>
<td>176 x 250 mm</td>
</tr>
<tr class="row-odd"><td>35</td>
<td>Envelope B6</td>
<td>176 x 125 mm</td>
</tr>
<tr class="row-even"><td>36</td>
<td>Envelope</td>
<td>110 x 230 mm</td>
</tr>
<tr class="row-odd"><td>37</td>
<td>Monarch</td>
<td>3.875 x 7.5 in</td>
</tr>
<tr class="row-even"><td>38</td>
<td>Envelope</td>
<td>3 5/8 x 6 1/2 in</td>
</tr>
<tr class="row-odd"><td>39</td>
<td>Fanfold</td>
<td>14 7/8 x 11 in</td>
</tr>
<tr class="row-even"><td>40</td>
<td>German Std Fanfold</td>
<td>8 1/2 x 12 in</td>
</tr>
<tr class="row-odd"><td>41</td>
<td>German Legal Fanfold</td>
<td>8 1/2 x 13 in</td>
</tr>
</tbody>
</table>
</div></blockquote>
<p>Note, it is likely that not all of these paper types will be available to the
end user since it will depend on the paper formats that the user’s printer
supports. Therefore, it is best to stick to standard paper types:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet</span><span class="o">.</span><span class="n">set_paper</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c"># US Letter</span>
<span class="n">worksheet</span><span class="o">.</span><span class="n">set_paper</span><span class="p">(</span><span class="mi">9</span><span class="p">)</span> <span class="c"># A4</span>
</pre></div>
</div>
<p>If you do not specify a paper type the worksheet will print using the printer’s
default paper style.</p>
</div>
<div class="section" id="worksheet-center-horizontally">
<h2>worksheet.center_horizontally()</h2>
<dl class="function">
<dt id="center_horizontally">
<tt class="descname">center_horizontally</tt><big>(</big><big>)</big></dt>
<dd><p>Center the printed page horizontally.</p>
</dd></dl>
<p>Center the worksheet data horizontally between the margins on the printed page:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet</span><span class="o">.</span><span class="n">center_horizontally</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="worksheet-center-vertically">
<h2>worksheet.center_vertically()</h2>
<dl class="function">
<dt id="center_vertically">
<tt class="descname">center_vertically</tt><big>(</big><big>)</big></dt>
<dd><p>Center the printed page vertically.</p>
</dd></dl>
<p>Center the worksheet data vertically between the margins on the printed page:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet</span><span class="o">.</span><span class="n">center_vertically</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="worksheet-worksheet-set-margins">
<h2>worksheet.worksheet.set_margins()</h2>
<dl class="function">
<dt id="set_margins">
<tt class="descname">set_margins</tt><big>(</big><em>[left=0.7,] right=0.7,] top=0.75,] bottom=0.75]]]</em><big>)</big></dt>
<dd><p>Set the worksheet margins for the printed page.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>left</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#float" title="(in Python v2.7)"><em>float</em></a>) – Left margin in inches. Default 0.7.</li>
<li><strong>right</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#float" title="(in Python v2.7)"><em>float</em></a>) – Right margin in inches. Default 0.7.</li>
<li><strong>top</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#float" title="(in Python v2.7)"><em>float</em></a>) – Top margin in inches. Default 0.75.</li>
<li><strong>bottom</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#float" title="(in Python v2.7)"><em>float</em></a>) – Bottom margin in inches. Default 0.75.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>The <tt class="docutils literal"><span class="pre">set_margins()</span></tt> method is used to set the margins of the worksheet when
it is printed. The units are in inches. All parameters are optional and have
default values corresponding to the default Excel values.</p>
</div>
<div class="section" id="worksheet-set-header">
<h2>worksheet.set_header()</h2>
<dl class="function">
<dt id="set_header">
<tt class="descname">set_header</tt><big>(</big><em>[header='',] margin=0.3]]</em><big>)</big></dt>
<dd><p>Set the printed page header caption and optional margin.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>header</strong> (<a class="reference external" href="http://docs.python.org/2/library/string.html#string" title="(in Python v2.7)"><em>string</em></a>) – Header string with Excel control characters.</li>
<li><strong>margin</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#float" title="(in Python v2.7)"><em>float</em></a>) – Header margin in inches. Default 0.3.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>Headers and footers are generated using a string which is a combination
of plain text and control characters.</p>
<p>The available control character are:</p>
<blockquote>
<div><table border="1" class="docutils">
<colgroup>
<col width="26%" />
<col width="26%" />
<col width="47%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Control</th>
<th class="head">Category</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&L</td>
<td>Justification</td>
<td>Left</td>
</tr>
<tr class="row-odd"><td>&C</td>
<td> </td>
<td>Center</td>
</tr>
<tr class="row-even"><td>&R</td>
<td> </td>
<td>Right</td>
</tr>
<tr class="row-odd"><td>&P</td>
<td>Information</td>
<td>Page number</td>
</tr>
<tr class="row-even"><td>&N</td>
<td> </td>
<td>Total number of pages</td>
</tr>
<tr class="row-odd"><td>&D</td>
<td> </td>
<td>Date</td>
</tr>
<tr class="row-even"><td>&T</td>
<td> </td>
<td>Time</td>
</tr>
<tr class="row-odd"><td>&F</td>
<td> </td>
<td>File name</td>
</tr>
<tr class="row-even"><td>&A</td>
<td> </td>
<td>Worksheet name</td>
</tr>
<tr class="row-odd"><td>&Z</td>
<td> </td>
<td>Workbook path</td>
</tr>
<tr class="row-even"><td>&fontsize</td>
<td>Font</td>
<td>Font size</td>
</tr>
<tr class="row-odd"><td>&”font,style”</td>
<td> </td>
<td>Font name and style</td>
</tr>
<tr class="row-even"><td>&U</td>
<td> </td>
<td>Single underline</td>
</tr>
<tr class="row-odd"><td>&E</td>
<td> </td>
<td>Double underline</td>
</tr>
<tr class="row-even"><td>&S</td>
<td> </td>
<td>Strikethrough</td>
</tr>
<tr class="row-odd"><td>&X</td>
<td> </td>
<td>Superscript</td>
</tr>
<tr class="row-even"><td>&Y</td>
<td> </td>
<td>Subscript</td>
</tr>
<tr class="row-odd"><td>&&</td>
<td>Miscellaneous</td>
<td>Literal ampersand &</td>
</tr>
</tbody>
</table>
</div></blockquote>
<p>Text in headers and footers can be justified (aligned) to the left, center and
right by prefixing the text with the control characters <tt class="docutils literal"><span class="pre">&L</span></tt>, <tt class="docutils literal"><span class="pre">&C</span></tt> and
<tt class="docutils literal"><span class="pre">&R</span></tt>.</p>
<p>For example (with ASCII art representation of the results):</p>
<div class="highlight-python"><pre>worksheet.set_header('&LHello')
---------------------------------------------------------------
| |
| Hello |
| |
$worksheet->set_header('&CHello');
---------------------------------------------------------------
| |
| Hello |
| |
$worksheet->set_header('&RHello');
---------------------------------------------------------------
| |
| Hello |
| |</pre>
</div>
<p>For simple text, if you do not specify any justification the text will be
centred. However, you must prefix the text with <tt class="docutils literal"><span class="pre">&C</span></tt> if you specify a font
name or any other formatting:</p>
<div class="highlight-python"><pre>worksheet.set_header('Hello')
---------------------------------------------------------------
| |
| Hello |
| |</pre>
</div>
<p>You can have text in each of the justification regions:</p>
<div class="highlight-python"><pre>worksheet.set_header('&LCiao&CBello&RCielo')
---------------------------------------------------------------
| |
| Ciao Bello Cielo |
| |</pre>
</div>
<p>The information control characters act as variables that Excel will update as
the workbook or worksheet changes. Times and dates are in the users default
format:</p>
<div class="highlight-python"><pre>worksheet.set_header('&CPage &P of &N')
---------------------------------------------------------------
| |
| Page 1 of 6 |
| |
worksheet.set_header('&CUpdated at &T')
---------------------------------------------------------------
| |
| Updated at 12:30 PM |
| |</pre>
</div>
<p>You can specify the font size of a section of the text by prefixing it with the
control character <tt class="docutils literal"><span class="pre">&n</span></tt> where <tt class="docutils literal"><span class="pre">n</span></tt> is the font size:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet1</span><span class="o">.</span><span class="n">set_header</span><span class="p">(</span><span class="s">'&C&30Hello Big'</span><span class="p">)</span>
<span class="n">worksheet2</span><span class="o">.</span><span class="n">set_header</span><span class="p">(</span><span class="s">'&C&10Hello Small'</span><span class="p">)</span>
</pre></div>
</div>
<p>You can specify the font of a section of the text by prefixing it with the
control sequence <tt class="docutils literal"><span class="pre">&"font,style"</span></tt> where <tt class="docutils literal"><span class="pre">fontname</span></tt> is a font name such as
“Courier New” or “Times New Roman” and <tt class="docutils literal"><span class="pre">style</span></tt> is one of the standard
Windows font descriptions: “Regular”, “Italic”, “Bold” or “Bold Italic”:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet1</span><span class="o">.</span><span class="n">set_header</span><span class="p">(</span><span class="s">'&C&"Courier New,Italic"Hello'</span><span class="p">)</span>
<span class="n">worksheet2</span><span class="o">.</span><span class="n">set_header</span><span class="p">(</span><span class="s">'&C&"Courier New,Bold Italic"Hello'</span><span class="p">)</span>
<span class="n">worksheet3</span><span class="o">.</span><span class="n">set_header</span><span class="p">(</span><span class="s">'&C&"Times New Roman,Regular"Hello'</span><span class="p">)</span>
</pre></div>
</div>
<p>It is possible to combine all of these features together to create
sophisticated headers and footers. As an aid to setting up complicated headers
and footers you can record a page set-up as a macro in Excel and look at the
format strings that VBA produces. Remember however that VBA uses two double
quotes <tt class="docutils literal"><span class="pre">""</span></tt> to indicate a single double quote. For the last example above
the equivalent VBA code looks like this:</p>
<div class="highlight-python"><pre>.LeftHeader = ""
.CenterHeader = "&""Times New Roman,Regular""Hello"
.RightHeader = ""</pre>
</div>
<p>To include a single literal ampersand <tt class="docutils literal"><span class="pre">&</span></tt> in a header or footer you should
use a double ampersand <tt class="docutils literal"><span class="pre">&&</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet1</span><span class="o">.</span><span class="n">set_header</span><span class="p">(</span><span class="s">'&CCuriouser and Curiouser - Attorneys at Law'</span><span class="p">)</span>
</pre></div>
</div>
<p>As stated above the margin parameter is optional. As with the other margins the
value should be in inches. The default header and footer margin is 0.3 inch.
The header and footer margin size can be set as follows:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet</span><span class="o">.</span><span class="n">set_header</span><span class="p">(</span><span class="s">'&CHello'</span><span class="p">,</span> <span class="mf">0.75</span><span class="p">)</span>
</pre></div>
</div>
<p>The header and footer margins are independent of the top and bottom margins.</p>
<p>Note, the header or footer string must be less than 255 characters. Strings
longer than this will not be written and an exception will be thrown.</p>
<p>See also <a class="reference internal" href="example_headers_footers.html#ex-headers-footers"><em>Example: Adding Headers and Footers to Worksheets</em></a>.</p>
</div>
<div class="section" id="worksheet-set-footer">
<h2>worksheet.set_footer()</h2>
<dl class="function">
<dt id="set_footer">
<tt class="descname">set_footer</tt><big>(</big><em>[footer='',] margin=0.3]]</em><big>)</big></dt>
<dd><p>Set the printed page footer caption and optional margin.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>footer</strong> (<a class="reference external" href="http://docs.python.org/2/library/string.html#string" title="(in Python v2.7)"><em>string</em></a>) – Footer string with Excel control characters.</li>
<li><strong>margin</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#float" title="(in Python v2.7)"><em>float</em></a>) – Footer margin in inches. Default 0.3.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>The syntax of the <tt class="docutils literal"><span class="pre">set_footer()</span></tt> method is the same as <a class="reference internal" href="#set_header" title="set_header"><tt class="xref py py-func docutils literal"><span class="pre">set_header()</span></tt></a>.</p>
</div>
<div class="section" id="worksheet-repeat-rows">
<h2>worksheet.repeat_rows()</h2>
<dl class="function">
<dt id="repeat_rows">
<tt class="descname">repeat_rows</tt><big>(</big><em>first_row</em><span class="optional">[</span>, <em>last_row</em><span class="optional">]</span><big>)</big></dt>
<dd><p>Set the number of rows to repeat at the top of each printed page.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>first_row</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a>) – First row of repeat range.</li>
<li><strong>last_row</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a>) – Last row of repeat range. Optional.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>For large Excel documents it is often desirable to have the first row or rows
of the worksheet print out at the top of each page.</p>
<p>This can be achieved by using the <tt class="docutils literal"><span class="pre">repeat_rows()</span></tt> method. The parameters
<tt class="docutils literal"><span class="pre">first_row</span></tt> and <tt class="docutils literal"><span class="pre">last_row</span></tt> are zero based. The <tt class="docutils literal"><span class="pre">last_row</span></tt> parameter is
optional if you only wish to specify one row:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet1</span><span class="o">.</span><span class="n">repeat_rows</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="c"># Repeat the first row.</span>
<span class="n">worksheet2</span><span class="o">.</span><span class="n">repeat_rows</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="c"># Repeat the first two rows.</span>
</pre></div>
</div>
</div>
<div class="section" id="worksheet-repeat-columns">
<h2>worksheet.repeat_columns()</h2>
<dl class="function">
<dt id="repeat_columns">
<tt class="descname">repeat_columns</tt><big>(</big><em>first_col</em><span class="optional">[</span>, <em>last_col</em><span class="optional">]</span><big>)</big></dt>
<dd><p>Set the columns to repeat at the left hand side of each printed page.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>first_col</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a>) – First column of repeat range.</li>
<li><strong>last_col</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a>) – Last column of repeat range. Optional.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>For large Excel documents it is often desirable to have the first column or
columns of the worksheet print out at the left hand side of each page.</p>
<p>This can be achieved by using the <tt class="docutils literal"><span class="pre">repeat_columns()</span></tt> method. The parameters
<tt class="docutils literal"><span class="pre">first_column</span></tt> and <tt class="docutils literal"><span class="pre">last_column</span></tt> are zero based. The <tt class="docutils literal"><span class="pre">last_column</span></tt>
parameter is optional if you only wish to specify one column. You can also
specify the columns using A1 column notation, see <a class="reference internal" href="working_with_cell_notation.html#cell-notation"><em>Working with Cell Notation</em></a> for
more details.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet1</span><span class="o">.</span><span class="n">repeat_columns</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="c"># Repeat the first column.</span>
<span class="n">worksheet2</span><span class="o">.</span><span class="n">repeat_columns</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="c"># Repeat the first two columns.</span>
<span class="n">worksheet3</span><span class="o">.</span><span class="n">repeat_columns</span><span class="p">(</span><span class="s">'A:A'</span><span class="p">)</span> <span class="c"># Repeat the first column.</span>
<span class="n">worksheet4</span><span class="o">.</span><span class="n">repeat_columns</span><span class="p">(</span><span class="s">'A:B'</span><span class="p">)</span> <span class="c"># Repeat the first two columns.</span>
</pre></div>
</div>
</div>
<div class="section" id="worksheet-hide-gridlines">
<h2>worksheet.hide_gridlines()</h2>
<dl class="function">
<dt id="hide_gridlines">
<tt class="descname">hide_gridlines</tt><big>(</big><span class="optional">[</span><em>option=1</em><span class="optional">]</span><big>)</big></dt>
<dd><p>Set the option to hide gridlines on the screen and the printed page.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>option</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a>) – Hide gridline options. See below.</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>This method is used to hide the gridlines on the screen and printed page.
Gridlines are the lines that divide the cells on a worksheet. Screen and
printed gridlines are turned on by default in an Excel worksheet.</p>
<p>If you have defined your own cell borders you may wish to hide the default
gridlines:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet</span><span class="o">.</span><span class="n">hide_gridlines</span><span class="p">()</span>
</pre></div>
</div>
<p>The following values of <tt class="docutils literal"><span class="pre">option</span></tt> are valid:</p>
<ol class="arabic simple" start="0">
<li>Don’t hide gridlines.</li>
<li>Hide printed gridlines only.</li>
<li>Hide screen and printed gridlines.</li>
</ol>
<p>If you don’t supply an argument the default option is 1, i.e. only the
printed gridlines are hidden.</p>
</div>
<div class="section" id="worksheet-print-row-col-headers">
<h2>worksheet.print_row_col_headers()</h2>
<dl class="function">
<dt id="print_row_col_headers">
<tt class="descname">print_row_col_headers</tt><big>(</big><big>)</big></dt>
<dd><p>Set the option to print the row and column headers on the printed page.</p>
</dd></dl>
<p>When you print a worksheet from Excel you get the data selected in the print
area. By default the Excel row and column headers (the row numbers on the left
and the column letters at the top) aren’t printed.</p>
<p>The <tt class="docutils literal"><span class="pre">print_row_col_headers()</span></tt> method sets the printer option to print these
headers:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet</span><span class="o">.</span><span class="n">print_row_col_headers</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="worksheet-print-area">
<h2>worksheet.print_area()</h2>
<dl class="function">
<dt id="print_area">
<tt class="descname">print_area</tt><big>(</big><em>first_row</em>, <em>first_col</em>, <em>last_row</em>, <em>last_col</em><big>)</big></dt>
<dd><p>Set the print area in the current worksheet.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>first_row</strong> (<em>integer</em>) – The first row of the range. (All zero indexed.)</li>
<li><strong>first_col</strong> (<em>integer</em>) – The first column of the range.</li>
<li><strong>last_row</strong> (<em>integer</em>) – The last row of the range.</li>
<li><strong>last_col</strong> (<em>integer</em>) – The last col of the range.</li>
<li><strong>formula</strong> – Array formula to write to cell.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>This method is used to specify the area of the worksheet that will be printed.</p>
<p>All four parameters must be specified. You can also use A1 notation, see
<a class="reference internal" href="working_with_cell_notation.html#cell-notation"><em>Working with Cell Notation</em></a>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet1</span><span class="o">.</span><span class="n">print_area</span><span class="p">(</span><span class="s">'A1:H20'</span><span class="p">)</span> <span class="c"># Cells A1 to H20.</span>
<span class="n">worksheet2</span><span class="o">.</span><span class="n">print_area</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span> <span class="c"># The same as above.</span>
<span class="n">worksheet3</span><span class="o">.</span><span class="n">print_area</span><span class="p">(</span><span class="s">'A:H'</span><span class="p">)</span> <span class="c"># Columns A to H if rows have data.</span>
</pre></div>
</div>
</div>
<div class="section" id="worksheet-print-across">
<h2>worksheet.print_across()</h2>
<dl class="function">
<dt id="print_across">
<tt class="descname">print_across</tt><big>(</big><big>)</big></dt>
<dd><p>Set the order in which pages are printed.</p>
</dd></dl>
<p>The <tt class="docutils literal"><span class="pre">print_across</span></tt> method is used to change the default print direction. This
is referred to by Excel as the sheet “page order”:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet</span><span class="o">.</span><span class="n">print_across</span><span class="p">()</span>
</pre></div>
</div>
<p>The default page order is shown below for a worksheet that extends over 4
pages. The order is called “down then across”:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">3</span><span class="p">]</span>
<span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="p">[</span><span class="mi">4</span><span class="p">]</span>
</pre></div>
</div>
<p>However, by using the <tt class="docutils literal"><span class="pre">print_across</span></tt> method the print order will be changed
to “across then down”:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="p">[</span><span class="mi">2</span><span class="p">]</span>
<span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="p">[</span><span class="mi">4</span><span class="p">]</span>
</pre></div>
</div>
</div>
<div class="section" id="worksheet-fit-to-pages">
<h2>worksheet.fit_to_pages()</h2>
<dl class="function">
<dt id="fit_to_pages">
<tt class="descname">fit_to_pages</tt><big>(</big><em>width</em>, <em>height</em><big>)</big></dt>
<dd><p>Fit the printed area to a specific number of pages both vertically and
horizontally.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>width</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a>) – Number of pages horizontally.</li>
<li><strong>height</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a>) – Number of pages vertically.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>The <tt class="docutils literal"><span class="pre">fit_to_pages()</span></tt> method is used to fit the printed area to a specific
number of pages both vertically and horizontally. If the printed area exceeds
the specified number of pages it will be scaled down to fit. This ensures
that the printed area will always appear on the specified number of pages
even if the page size or margins change:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet1</span><span class="o">.</span><span class="n">fit_to_pages</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="c"># Fit to 1x1 pages.</span>
<span class="n">worksheet2</span><span class="o">.</span><span class="n">fit_to_pages</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="c"># Fit to 2x1 pages.</span>
<span class="n">worksheet3</span><span class="o">.</span><span class="n">fit_to_pages</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="c"># Fit to 1x2 pages.</span>
</pre></div>
</div>
<p>The print area can be defined using the <tt class="docutils literal"><span class="pre">print_area()</span></tt> method as described
above.</p>
<p>A common requirement is to fit the printed output to <tt class="docutils literal"><span class="pre">n</span></tt> pages wide but have
the height be as long as necessary. To achieve this set the <tt class="docutils literal"><span class="pre">height</span></tt> to
zero:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet1</span><span class="o">.</span><span class="n">fit_to_pages</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="c"># 1 page wide and as long as necessary.</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Although it is valid to use both <a class="reference internal" href="#fit_to_pages" title="fit_to_pages"><tt class="xref py py-func docutils literal"><span class="pre">fit_to_pages()</span></tt></a> and
<a class="reference internal" href="#set_print_scale" title="set_print_scale"><tt class="xref py py-func docutils literal"><span class="pre">set_print_scale()</span></tt></a> on the same worksheet only one of these options
can be active at a time. The last method call made will set the active
option.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <a class="reference internal" href="#fit_to_pages" title="fit_to_pages"><tt class="xref py py-func docutils literal"><span class="pre">fit_to_pages()</span></tt></a> will override any manual page breaks that are
defined in the worksheet.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">When using <a class="reference internal" href="#fit_to_pages" title="fit_to_pages"><tt class="xref py py-func docutils literal"><span class="pre">fit_to_pages()</span></tt></a> it may also be required to set the
printer paper size using <a class="reference internal" href="#set_paper" title="set_paper"><tt class="xref py py-func docutils literal"><span class="pre">set_paper()</span></tt></a> or else Excel will default
to “US Letter”.</p>
</div>
</div>
<div class="section" id="worksheet-set-start-page">
<h2>worksheet.set_start_page()</h2>
<dl class="function">
<dt id="set_start_page">
<tt class="descname">set_start_page</tt><big>(</big><big>)</big></dt>
<dd><p>Set the start page number when printing.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>start_page</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a>) – Starting page number.</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>The <tt class="docutils literal"><span class="pre">set_start_page()</span></tt> method is used to set the number of the starting page
when the worksheet is printed out:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet</span><span class="o">.</span><span class="n">set_start_page</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="worksheet-set-print-scale">
<h2>worksheet.set_print_scale()</h2>
<dl class="function">
<dt id="set_print_scale">
<tt class="descname">set_print_scale</tt><big>(</big><big>)</big></dt>
<dd><p>Set the scale factor for the printed page.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>scale</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a>) – Print scale of worksheet to be printed.</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>Set the scale factor of the printed page. Scale factors in the range
<tt class="docutils literal"><span class="pre">10</span> <span class="pre"><=</span> <span class="pre">$scale</span> <span class="pre"><=</span> <span class="pre">400</span></tt> are valid:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet1</span><span class="o">.</span><span class="n">set_print_scale</span><span class="p">(</span><span class="mi">50</span><span class="p">)</span>
<span class="n">worksheet2</span><span class="o">.</span><span class="n">set_print_scale</span><span class="p">(</span><span class="mi">75</span><span class="p">)</span>
<span class="n">worksheet3</span><span class="o">.</span><span class="n">set_print_scale</span><span class="p">(</span><span class="mi">300</span><span class="p">)</span>
<span class="n">worksheet4</span><span class="o">.</span><span class="n">set_print_scale</span><span class="p">(</span><span class="mi">400</span><span class="p">)</span>
</pre></div>
</div>
<p>The default scale factor is 100. Note, <tt class="docutils literal"><span class="pre">set_print_scale()</span></tt> does not affect
the scale of the visible page in Excel. For that you should use
<a class="reference internal" href="worksheet.html#set_zoom" title="set_zoom"><tt class="xref py py-func docutils literal"><span class="pre">set_zoom()</span></tt></a>.</p>
<p>Note also that although it is valid to use both <tt class="docutils literal"><span class="pre">fit_to_pages()</span></tt> and
<tt class="docutils literal"><span class="pre">set_print_scale()</span></tt> on the same worksheet only one of these options can
be active at a time. The last method call made will set the active option.</p>
</div>
<div class="section" id="worksheet-set-h-pagebreaks">
<h2>worksheet.set_h_pagebreaks()</h2>
<dl class="function">
<dt id="set_h_pagebreaks">
<tt class="descname">set_h_pagebreaks</tt><big>(</big><em>breaks</em><big>)</big></dt>
<dd><p>Set the horizontal page breaks on a worksheet.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>breaks</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#list" title="(in Python v2.7)"><em>list</em></a>) – List of pagebreak rows.</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>The <tt class="docutils literal"><span class="pre">set_h_pagebreaks()</span></tt> method adds horizontal page breaks to a worksheet.
A page break causes all the data that follows it to be printed on the next
page. Horizontal page breaks act between rows. To create a page break between
rows 20 and 21 you must specify the break at row 21. However in zero index
notation this is actually row 20. So you can pretend for a small while that
you are using 1 index notation:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet1</span><span class="o">.</span><span class="n">set_h_pagebreaks</span><span class="p">([</span><span class="mi">20</span><span class="p">])</span> <span class="c"># Break between row 20 and 21.</span>
</pre></div>
</div>
<p>The <tt class="docutils literal"><span class="pre">set_v_pagebreaks()</span></tt> method takes a list of page breaks:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">worksheet2</span><span class="o">.</span><span class="n">set_v_pagebreaks</span><span class="p">([</span><span class="mi">20</span><span class="p">,</span> <span class="mi">40</span><span class="p">,</span> <span class="mi">60</span><span class="p">,</span> <span class="mi">80</span><span class="p">,</span> <span class="mi">100</span><span class="p">])</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Note: If you specify the “fit to page” option via the <tt class="docutils literal"><span class="pre">fit_to_pages()</span></tt>
method it will override all manual page breaks.</p>
</div>
<p>There is a silent limitation of 1023 horizontal page breaks per worksheet
in line with an Excel internal limitation.</p>
</div>
<div class="section" id="worksheet-set-v-pagebreaks">
<h2>worksheet.set_v_pagebreaks()</h2>
<dl class="function">
<dt id="set_v_pagebreaks">
<tt class="descname">set_v_pagebreaks</tt><big>(</big><em>breaks</em><big>)</big></dt>
<dd><p>Set the vertical page breaks on a worksheet.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>breaks</strong> (<a class="reference external" href="http://docs.python.org/2/library/functions.html#list" title="(in Python v2.7)"><em>list</em></a>) – List of pagebreak columns.</td>
</tr>
</tbody>
</table>
</dd></dl>
<p>The <tt class="docutils literal"><span class="pre">set_v_pagebreaks()</span></tt> method is the same as the above
<a class="reference internal" href="#set_h_pagebreaks" title="set_h_pagebreaks"><tt class="xref py py-func docutils literal"><span class="pre">set_h_pagebreaks()</span></tt></a> method except it adds page breaks between columns.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/logo.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">The Worksheet Class (Page Setup)</a><ul>
<li><a class="reference internal" href="#worksheet-set-landscape">worksheet.set_landscape()</a></li>
<li><a class="reference internal" href="#worksheet-set-portrait">worksheet.set_portrait()</a></li>
<li><a class="reference internal" href="#worksheet-set-page-view">worksheet.set_page_view()</a></li>
<li><a class="reference internal" href="#worksheet-set-paper">worksheet.set_paper()</a></li>
<li><a class="reference internal" href="#worksheet-center-horizontally">worksheet.center_horizontally()</a></li>
<li><a class="reference internal" href="#worksheet-center-vertically">worksheet.center_vertically()</a></li>
<li><a class="reference internal" href="#worksheet-worksheet-set-margins">worksheet.worksheet.set_margins()</a></li>
<li><a class="reference internal" href="#worksheet-set-header">worksheet.set_header()</a></li>
<li><a class="reference internal" href="#worksheet-set-footer">worksheet.set_footer()</a></li>
<li><a class="reference internal" href="#worksheet-repeat-rows">worksheet.repeat_rows()</a></li>
<li><a class="reference internal" href="#worksheet-repeat-columns">worksheet.repeat_columns()</a></li>
<li><a class="reference internal" href="#worksheet-hide-gridlines">worksheet.hide_gridlines()</a></li>
<li><a class="reference internal" href="#worksheet-print-row-col-headers">worksheet.print_row_col_headers()</a></li>
<li><a class="reference internal" href="#worksheet-print-area">worksheet.print_area()</a></li>
<li><a class="reference internal" href="#worksheet-print-across">worksheet.print_across()</a></li>
<li><a class="reference internal" href="#worksheet-fit-to-pages">worksheet.fit_to_pages()</a></li>
<li><a class="reference internal" href="#worksheet-set-start-page">worksheet.set_start_page()</a></li>
<li><a class="reference internal" href="#worksheet-set-print-scale">worksheet.set_print_scale()</a></li>
<li><a class="reference internal" href="#worksheet-set-h-pagebreaks">worksheet.set_h_pagebreaks()</a></li>
<li><a class="reference internal" href="#worksheet-set-v-pagebreaks">worksheet.set_v_pagebreaks()</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="worksheet.html"
title="previous chapter">The Worksheet Class</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="format.html"
title="next chapter">The Format Class</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/page_setup.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>