Skip to content

Commit 78e0ebb

Browse files
authored
[excel] (Table, Application) Adding samples to high view pages (#316)
* Adding samples to high view pages * Typo fix
1 parent fa75149 commit 78e0ebb

File tree

6 files changed

+136
-8
lines changed

6 files changed

+136
-8
lines changed

docs/docs-ref-autogen/excel/excelscript/excelscript.datetimeformatinfo.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,23 @@ methods:
8585
content: 'getLongDatePattern(): string;'
8686
return:
8787
type: string
88-
description: ''
88+
description: |-
89+
90+
91+
#### Examples
92+
93+
```TypeScript
94+
/**
95+
* This script returns the system's long date pattern.
96+
* This could be used in a Power Automate flow to keep date formatting consistent.
97+
*/
98+
function main(workbook: ExcelScript.Workbook) : string {
99+
const cultureInfo = workbook.getApplication().getCultureInfo();
100+
const dateTimeInfo = cultureInfo.getDatetimeFormat();
101+
102+
return dateTimeInfo.getLongDatePattern();
103+
}
104+
```
89105
- name: getLongTimePattern()
90106
uid: 'ExcelScript!ExcelScript.DatetimeFormatInfo#getLongTimePattern:member(1)'
91107
package: ExcelScript!

docs/docs-ref-autogen/excel/excelscript/excelscript.filter.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@ uid: 'ExcelScript!ExcelScript.Filter:interface'
44
package: ExcelScript!
55
fullName: ExcelScript.Filter
66
summary: Manages the filtering of a table's column.
7-
remarks: ''
7+
remarks: |-
8+
9+
10+
#### Examples
11+
12+
```TypeScript
13+
/**
14+
* This script adds a table filter to only show the top 10% of values
15+
* belonging to a particular column.
16+
*/
17+
function main(workbook: ExcelScript.Workbook) {
18+
// Get the first table on the current worksheet.
19+
const table = workbook.getActiveWorksheet().getTables()[0];
20+
21+
// Get the filter for the "PageViews" table column.
22+
const pageViewFilter : ExcelScript.Filter = table.getColumnByName("PageViews").getFilter();
23+
24+
// Apply a filter to only show the rows in the top 10% of values in this column.
25+
pageViewFilter.applyTopPercentFilter(10);
26+
}
27+
```
828
isPreview: false
929
isDeprecated: false
1030
type: interface

docs/docs-ref-autogen/excel/excelscript/excelscript.table.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,23 @@ methods:
892892
type: boolean
893893
return:
894894
type: void
895-
description: ''
895+
description: |-
896+
897+
898+
#### Examples
899+
900+
```TypeScript
901+
/**
902+
* This script makes a table's headers not visible in the grid.
903+
*/
904+
function main(workbook: ExcelScript.Workbook) {
905+
// Get the table named "CoverageTable".
906+
const coverageTable = workbook.getTable("CoverageTable");
907+
908+
// Make the header row not visible.
909+
coverageTable.setShowHeaders(false);
910+
}
911+
```
896912
- name: setShowTotals(showTotals)
897913
uid: 'ExcelScript!ExcelScript.Table#setShowTotals:member(1)'
898914
package: ExcelScript!

docs/docs-ref-autogen/excel/excelscript/excelscript.tablecolumn.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,27 @@ methods:
5353
content: 'getFilter(): Filter;'
5454
return:
5555
type: '<xref uid="ExcelScript!ExcelScript.Filter:interface" />'
56-
description: ''
56+
description: |-
57+
58+
59+
#### Examples
60+
61+
```TypeScript
62+
/**
63+
* This script adds a table filter to only show the top 10% of values
64+
* belonging to a particular column.
65+
*/
66+
function main(workbook: ExcelScript.Workbook) {
67+
// Get the first table on the current worksheet.
68+
const table = workbook.getActiveWorksheet().getTables()[0];
69+
70+
// Get the filter for the "PageViews" table column.
71+
const pageViewFilter = table.getColumnByName("PageViews").getFilter();
72+
73+
// Apply a filter to only show the rows in the top 10% of values in this column.
74+
pageViewFilter.applyTopPercentFilter(10);
75+
}
76+
```
5777
- name: getHeaderRowRange()
5878
uid: 'ExcelScript!ExcelScript.TableColumn#getHeaderRowRange:member(1)'
5979
package: ExcelScript!

docs/sample-scripts/excel-scripts.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,18 @@
19781978
// Write the date using the system's separator character.
19791979
cell.setValue(`${currentDate.getMonth()}${separator}${currentDate.getDate()}${separator}${currentDate.getFullYear()}`);
19801980
}
1981+
'ExcelScript.DatetimeFormatInfo#getLongDatePattern:member(1)':
1982+
- |-
1983+
/**
1984+
* This script returns the system's long date pattern.
1985+
* This could be used in a Power Automate flow to keep date formatting consistent.
1986+
*/
1987+
function main(workbook: ExcelScript.Workbook) : string {
1988+
const cultureInfo = workbook.getApplication().getCultureInfo();
1989+
const dateTimeInfo = cultureInfo.getDatetimeFormat();
1990+
1991+
return dateTimeInfo.getLongDatePattern();
1992+
}
19811993
'ExcelScript.DatetimeFormatInfo#getTimeSeparator:member(1)':
19821994
- |-
19831995
/**
@@ -2130,6 +2142,22 @@
21302142
selected.getFormat().getFill().setPattern(ExcelScript.FillPattern.checker);
21312143
selected.getFormat().getFill().setPatternColor("black");
21322144
}
2145+
'ExcelScript.Filter:interface':
2146+
- |-
2147+
/**
2148+
* This script adds a table filter to only show the top 10% of values
2149+
* belonging to a particular column.
2150+
*/
2151+
function main(workbook: ExcelScript.Workbook) {
2152+
// Get the first table on the current worksheet.
2153+
const table = workbook.getActiveWorksheet().getTables()[0];
2154+
2155+
// Get the filter for the "PageViews" table column.
2156+
const pageViewFilter : ExcelScript.Filter = table.getColumnByName("PageViews").getFilter();
2157+
2158+
// Apply a filter to only show the rows with the top 10% of values in this column.
2159+
pageViewFilter.applyTopPercentFilter(10);
2160+
}
21332161
'ExcelScript.Filter#applyCustomFilter:member(1)':
21342162
- |-
21352163
/**
@@ -5433,6 +5461,18 @@
54335461
table.reapplyFilters();
54345462
});
54355463
}
5464+
'ExcelScript.Table#setShowHeaders:member(1)':
5465+
- |-
5466+
/**
5467+
* This script makes a table's headers not visible in the grid.
5468+
*/
5469+
function main(workbook: ExcelScript.Workbook) {
5470+
// Get the table named "CoverageTable".
5471+
const coverageTable = workbook.getTable("CoverageTable");
5472+
5473+
// Make the header row not visible.
5474+
coverageTable.setShowHeaders(false);
5475+
}
54365476
'ExcelScript.Table#setShowTotals:member(1)':
54375477
- |-
54385478
/**
@@ -5461,6 +5501,22 @@
54615501
categoryColumn.delete();
54625502
}
54635503
}
5504+
'ExcelScript.TableColumn#getFilter:member(1)':
5505+
- |-
5506+
/**
5507+
* This script adds a table filter to only show the top 10% of values
5508+
* belonging to a particular column.
5509+
*/
5510+
function main(workbook: ExcelScript.Workbook) {
5511+
// Get the first table on the current worksheet.
5512+
const table = workbook.getActiveWorksheet().getTables()[0];
5513+
5514+
// Get the filter for the "PageViews" table column.
5515+
const pageViewFilter = table.getColumnByName("PageViews").getFilter();
5516+
5517+
// Apply a filter to only show the rows with the top 10% of values in this column.
5518+
pageViewFilter.applyTopPercentFilter(10);
5519+
}
54645520
'ExcelScript.TableColumn#getRangeBetweenHeaderAndTotal:member(1)':
54655521
- |-
54665522
/**

generate-docs/API Coverage Report.csv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ ExcelScript.DateTimeDataValidation,"formula2",Property,Good,false
14711471
ExcelScript.DateTimeDataValidation,"operator",Property,Fine,false
14721472
ExcelScript.DatetimeFormatInfo,N/A,Class,Good,true
14731473
ExcelScript.DatetimeFormatInfo,"getDateSeparator()",Method,Fine,true
1474-
ExcelScript.DatetimeFormatInfo,"getLongDatePattern()",Method,Poor,false
1474+
ExcelScript.DatetimeFormatInfo,"getLongDatePattern()",Method,Good,true
14751475
ExcelScript.DatetimeFormatInfo,"getLongTimePattern()",Method,Poor,false
14761476
ExcelScript.DatetimeFormatInfo,"getShortDatePattern()",Method,Poor,false
14771477
ExcelScript.DatetimeFormatInfo,"getTimeSeparator()",Method,Fine,true
@@ -1567,7 +1567,7 @@ ExcelScript.FillPattern,"semiGray75",EnumField,Missing,false
15671567
ExcelScript.FillPattern,"solid",EnumField,Missing,false
15681568
ExcelScript.FillPattern,"up",EnumField,Missing,false
15691569
ExcelScript.FillPattern,"vertical",EnumField,Missing,false
1570-
ExcelScript.Filter,N/A,Class,Fine,false
1570+
ExcelScript.Filter,N/A,Class,Fine,true
15711571
ExcelScript.Filter,"apply(criteria)",Method,Poor,false
15721572
ExcelScript.Filter,"applyBottomItemsFilter(count)",Method,Poor,false
15731573
ExcelScript.Filter,"applyBottomPercentFilter(percent)",Method,Poor,false
@@ -3018,11 +3018,11 @@ ExcelScript.Table,"setPredefinedTableStyle(predefinedTableStyle)",Method,Poor,fa
30183018
ExcelScript.Table,"setShowBandedColumns(showBandedColumns)",Method,Poor,false
30193019
ExcelScript.Table,"setShowBandedRows(showBandedRows)",Method,Poor,false
30203020
ExcelScript.Table,"setShowFilterButton(showFilterButton)",Method,Poor,false
3021-
ExcelScript.Table,"setShowHeaders(showHeaders)",Method,Poor,false
3021+
ExcelScript.Table,"setShowHeaders(showHeaders)",Method,Poor,true
30223022
ExcelScript.Table,"setShowTotals(showTotals)",Method,Poor,true
30233023
ExcelScript.TableColumn,N/A,Class,Fine,false
30243024
ExcelScript.TableColumn,"delete()",Method,Poor,true
3025-
ExcelScript.TableColumn,"getFilter()",Method,Poor,false
3025+
ExcelScript.TableColumn,"getFilter()",Method,Poor,true
30263026
ExcelScript.TableColumn,"getHeaderRowRange()",Method,Poor,false
30273027
ExcelScript.TableColumn,"getId()",Method,Poor,false
30283028
ExcelScript.TableColumn,"getIndex()",Method,Poor,false

0 commit comments

Comments
 (0)