You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/excel/excel-add-ins-worksheet-display.md
+48-39
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,46 @@ ms.localizationpriority: medium
9
9
10
10
Excel is often used for reporting scenarios where you want to share worksheet data with others. Your Office Add-in can reduce visual clutter and help focus attention by controlling the appearance of the worksheet. The Office JavaScript API supports changing several visual aspects of the worksheet.
11
11
12
-
## Turn data type icons on or off
12
+
## Page layout and print settings
13
+
14
+
Add-ins have access to page layout settings at a worksheet level. These control how the sheet is printed. A `Worksheet` object has three layout-related properties: `horizontalPageBreaks`, `verticalPageBreaks`, `pageLayout`.
15
+
16
+
`Worksheet.horizontalPageBreaks` and `Worksheet.verticalPageBreaks` are [PageBreakCollections](/javascript/api/excel/excel.pagebreakcollection). These are collections of [PageBreaks](/javascript/api/excel/excel.pagebreak), which specify ranges where manual page breaks are inserted. The following code sample adds a horizontal page break above row **21**.
sheet.horizontalPageBreaks.add("A21:E21"); // The page break is added above this range.
22
+
awaitcontext.sync();
23
+
});
24
+
```
25
+
26
+
`Worksheet.pageLayout` is a [PageLayout](/javascript/api/excel/excel.pagelayout) object. This object contains layout and print settings that are not dependent any printer-specific implementation. These settings include margins, orientation, page numbering, title rows, and print area.
27
+
28
+
The following code sample centers the page (both vertically and horizontally), sets a title row that will be printed at the top of every page, and sets the printed area to a subsection of the worksheet.
> If a linked data type displays a **?** icon, this can’t be toggled on or off. Excel needs the user to disambiguate the cell value to find the correct data type. For more information, see [Excel data types: Stocks and geography](https://support.microsoft.com/office/61a33056-9935-484f-8ac8-f1a89e210877).
32
71
33
-
## Show or hide the worksheet gridlines
72
+
## Show or hide the worksheet gridlines (preview)
73
+
74
+
> [!NOTE]
75
+
> [!INCLUDE [Information about using preview APIs](../includes/using-excel-preview-apis.md)]
34
76
35
77
Gridlines are the faint lines that appear between cells on a worksheet. These can be distracting if you use shapes, icons, or have specific line and border formats on data.
> [!INCLUDE [Information about using preview APIs](../includes/using-excel-preview-apis.md)]
52
97
53
98
Headings are the Excel row numbers that appear on the left side of the worksheet (1, 2, 3) and the column letters that appear at the top of the worksheet (A, B, C). The user may not want these in their report.
Add-ins have access to page layout settings at a worksheet level. These control how the sheet is printed. A `Worksheet` object has three layout-related properties: `horizontalPageBreaks`, `verticalPageBreaks`, `pageLayout`.
70
-
71
-
`Worksheet.horizontalPageBreaks` and `Worksheet.verticalPageBreaks` are [PageBreakCollections](/javascript/api/excel/excel.pagebreakcollection). These are collections of [PageBreaks](/javascript/api/excel/excel.pagebreak), which specify ranges where manual page breaks are inserted. The following code sample adds a horizontal page break above row **21**.
72
-
73
-
```js
74
-
awaitExcel.run(async (context) => {
75
-
let sheet =context.workbook.worksheets.getActiveWorksheet();
76
-
sheet.horizontalPageBreaks.add("A21:E21"); // The page break is added above this range.
77
-
awaitcontext.sync();
78
-
});
79
-
```
80
-
81
-
`Worksheet.pageLayout` is a [PageLayout](/javascript/api/excel/excel.pagelayout) object. This object contains layout and print settings that are not dependent any printer-specific implementation. These settings include margins, orientation, page numbering, title rows, and print area.
82
-
83
-
The following code sample centers the page (both vertically and horizontally), sets a title row that will be printed at the top of every page, and sets the printed area to a subsection of the worksheet.
84
-
85
-
```js
86
-
awaitExcel.run(async (context) => {
87
-
let sheet =context.workbook.worksheets.getActiveWorksheet();
88
-
89
-
// Center the page in both directions.
90
-
sheet.pageLayout.centerHorizontally=true;
91
-
sheet.pageLayout.centerVertically=true;
92
-
93
-
// Set the first row as the title row for every page.
94
-
sheet.pageLayout.setPrintTitleRows("$1:$1");
95
-
96
-
// Limit the area to be printed to the range "A1:D100".
97
-
sheet.pageLayout.setPrintArea("A1:D100");
98
-
99
-
awaitcontext.sync();
100
-
});
101
-
```
102
-
103
112
## See also
104
113
105
114
-[Excel JavaScript object model in Office Add-ins](excel-add-ins-core-concepts.md)
0 commit comments