Skip to content

Commit adf074e

Browse files
authored
[excel] (Samples) Add buttons to workbook downloads (#665)
* Test button * BUtton as next step * Add more buttons * Revert zip file download links * More buttons * Comment sample test * Make the button not seem optional * Typo fix
1 parent 2eac92c commit adf074e

16 files changed

+116
-39
lines changed

docs/develop/pivottables.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Work with PivotTables in Office Scripts
33
description: Learn about the object model for PivotTables in the Office Scripts JavaScript API.
4-
ms.date: 09/08/2023
4+
ms.date: 10/19/2023
55
ms.localizationpriority: medium
66
---
77

@@ -26,7 +26,10 @@ The [PivotTable](/javascript/api/office-scripts/excelscript/excelscript.pivottab
2626
- The [PivotLayout](/javascript/api/office-scripts/excelscript/excelscript.pivotlayout) defines how the [PivotFields](/javascript/api/office-scripts/excelscript/excelscript.pivotfield) and [PivotItems](/javascript/api/office-scripts/excelscript/excelscript.pivotitem) are displayed.
2727
- [PivotFilters](/javascript/api/office-scripts/excelscript/excelscript.pivotfilters) filter data from the [PivotTable](/javascript/api/office-scripts/excelscript/excelscript.pivottable) using different criteria.
2828

29-
Look at how these relationships work in practice. The following data describes fruit sales from various farms. It's the base for all the examples in this article. Use [pivottable-sample.xlsx](pivottable-sample.xlsx) to follow along.
29+
To look at how these relationships work in practice, start by downloading the sample workbook. That data describes fruit sales from various farms. It's the base for all the examples in this article. Run the sample scripts throughout the article to create and explore PivotTables.
30+
31+
> [!div class="nextstepaction"]
32+
> [Download the sample workbook](pivottable-sample.xlsx)
3033
3134
:::image type="content" source="../images/pivottable-raw-data.png" alt-text="A collection of fruit sales of different types from different farms.":::
3235

docs/resources/samples/add-excel-comments.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Add comments in Excel
33
description: Learn how to use Office Scripts to add comments in a worksheet.
4-
ms.date: 08/14/2023
4+
ms.date: 10/20/2023
55
ms.localizationpriority: medium
66
---
77

@@ -11,22 +11,25 @@ This sample shows how to add comments to a cell including [@mentioning](https://
1111

1212
## Example scenario
1313

14-
* The team lead maintains the shift schedule. The team lead assigns an employee ID to the shift record.
15-
* The team lead wishes to notify the employee. By adding a comment that @mentions the employee, the employee is emailed with a custom message from the worksheet.
16-
* Subsequently, the employee can view the workbook and respond to the comment at their convenience.
14+
The team lead maintains the shift schedule. They assign an employee ID to the shift record. If the team lead wishes to notify the employee, they add a comment that @mentions the employee. The employee is emailed with a custom message from the worksheet. Subsequently, the employee can view the workbook and respond to the comment at their convenience.
1715

1816
## Solution
1917

2018
1. The script extracts employee information from the employee worksheet.
2119
1. The script then adds a comment (including the relevant employee email) to the appropriate cell in the shift record.
2220
1. Existing comments in the cell are removed before adding the new comment.
2321

24-
## Sample Excel file
22+
## Setup: Sample Excel file
2523

26-
Download [add-excel-comments.xlsx](add-excel-comments.xlsx) for a ready-to-use workbook. Add the following script to try the sample yourself!
24+
This workbook contains the data, objects, and formatting expected by the script.
25+
26+
> [!div class="nextstepaction"]
27+
> [Download the sample workbook](add-excel-comments.xlsx)
2728
2829
## Sample code: Add comments
2930

31+
Add the following script to the sample workbook and try the sample yourself!
32+
3033
```TypeScript
3134
function main(workbook: ExcelScript.Workbook) {
3235
// Get the list of employees.

docs/resources/samples/add-image-to-workbook.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ The first sample copies an image from one worksheet to another. This could be us
1717

1818
The second sample copies an image from a URL. This could be used to copy photos that a colleague stored in a shared folder to a related workbook. Please note that this sample can't be adapted to work with a local image file, as that isn't supported by Office Scripts.
1919

20-
## Sample Excel file
20+
## Setup: Sample Excel file
2121

22-
Download [add-images.xlsx](add-images.xlsx) for a ready-to-use workbook. Add the following scripts and try the sample yourself!
22+
This workbook contains the data, objects, and formatting expected by the script.
23+
24+
> [!div class="nextstepaction"]
25+
> [Download the sample workbook](add-images.xlsx)
2326
2427
## Sample code: Copy an image across worksheets
2528

29+
Add the following script to the sample workbook and try the sample yourself!
30+
2631
```TypeScript
2732
/**
2833
* This script transfers an image from one worksheet to another.

docs/resources/samples/community-seasons-greetings.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,16 @@ Enjoy!
1313

1414
[Watch the Seasons greetings script in action on the "Les's IT Blog" YouTube channel](https://youtu.be/HBiGEkzmkgo).
1515

16-
## Script
16+
## Setup: Sample Excel file
1717

18-
Download [happy-tree.xlsx](happy-tree.xlsx) for a ready-to-use workbook. Add the following script to try the sample yourself!
18+
This workbook contains the data, objects, and formatting expected by the script.
19+
20+
> [!div class="nextstepaction"]
21+
> [Download the sample workbook](happy-tree.xlsx)
22+
23+
## Sample code: Happy tree
24+
25+
Add the following script to the sample workbook and try the sample yourself!
1926

2027
```TypeScript
2128
/* Original version by Leslie Black. */

docs/resources/samples/copy-tables-combine.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ There are two variations of this script:
1414
1. The [first script](#sample-code-combine-data-from-multiple-excel-tables-into-a-single-table) combines all tables in the Excel file.
1515
1. The [second script](#sample-code-combine-data-from-multiple-excel-tables-in-select-worksheets-into-a-single-table) selectively gets tables within a set of worksheets.
1616

17-
## Sample Excel file
17+
## Setup: Sample Excel file
1818

19-
Download [tables-copy.xlsx](tables-copy.xlsx) for a ready-to-use workbook. Add the following scripts to try the sample yourself!
19+
This workbook contains the data, objects, and formatting expected by the script.
20+
21+
> [!div class="nextstepaction"]
22+
> [Download the sample workbook](tables-copy.xlsx)
2023
2124
## Sample code: Combine data from multiple Excel tables into a single table
2225

26+
Add the following script to the sample workbook and try the sample yourself!
27+
2328
```TypeScript
2429
function main(workbook: ExcelScript.Workbook) {
2530
// Delete the "Combined" worksheet, if it's present.

docs/resources/samples/email-images-chart-table.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ This solution has two parts:
3535
1. [An Office Script to calculate and extract Excel chart and table](#sample-code-calculate-and-extract-excel-chart-and-table)
3636
1. A Power Automate flow to invoke the script and email the results. For an example on how to do this, see [Create an automated workflow with Power Automate](../../tutorials/excel-power-automate-returns.md#create-an-automated-workflow-with-power-automate).
3737

38-
## Sample Excel file
38+
## Setup: Sample Excel file
3939

40-
Download [email-chart-table.xlsx](email-chart-table.xlsx) for a ready-to-use workbook. Add the following script to try the sample yourself!
40+
This workbook contains the data, objects, and formatting expected by the script.
41+
42+
> [!div class="nextstepaction"]
43+
> [Download the sample workbook](email-chart-table.xlsx)
4144
4245
## Sample code: Calculate and extract Excel chart and table
4346

47+
Add the following script to the sample workbook and try the sample yourself!
48+
4449
```TypeScript
4550
function main(workbook: ExcelScript.Workbook): ReportImages {
4651
// Recalculate the workbook to ensure all tables and charts are updated.

docs/resources/samples/get-table-data.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ ms.localizationpriority: medium
99

1010
Excel table data can be represented as an array of objects in the form of [JSON](https://www.w3schools.com/whatis/whatis_json.asp). Each object represents a row in the table. This helps extract the data from Excel in a consistent format that is visible to the user. The data can then be given to other systems through Power Automate flows.
1111

12-
## Sample Excel file
12+
## Setup: Sample Excel file
1313

14-
Download the file [table-data-with-hyperlinks.xlsx](table-data-with-hyperlinks.xlsx) for a ready-to-use workbook.
14+
This workbook contains the data, objects, and formatting expected by the script.
15+
16+
> [!div class="nextstepaction"]
17+
> [Download the sample workbook](table-data-with-hyperlinks.xlsx)
1518
1619
:::image type="content" source="../../images/table-input.png" alt-text="A worksheet showing input table data.":::
1720

@@ -21,7 +24,7 @@ A variation of this sample also includes the hyperlinks in one of the table colu
2124

2225
## Sample code: Return table data as JSON
2326

24-
Add the following script to try the sample yourself!
27+
Add the following script to the sample workbook and try the sample yourself!
2528

2629
> [!NOTE]
2730
> You can change the `interface TableData` structure to match your table columns. Note that for column names with spaces, be sure to place your key in quotation marks, such as with `"Event ID"` in the sample. For more information about working with JSON, read [Use JSON to pass data to and from Office Scripts](../../develop/use-json.md).

docs/resources/samples/move-rows-across-tables.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ This script does the following:
1313
* Moves all selected rows into the target table in another worksheet.
1414
* Reapplies the relevant filters to the source table.
1515

16-
## Sample Excel file
16+
## Setup: Sample Excel file
1717

18-
Download the file [input-table-filters.xlsx](input-table-filters.xlsx) for a ready-to-use workbook. Add the following script to try the sample yourself!
18+
This workbook contains the data, objects, and formatting expected by the script.
19+
20+
> [!div class="nextstepaction"]
21+
> [Download the sample workbook](input-table-filters.xlsx)
1922
2023
## Sample code: Move rows using range values
2124

25+
Add the following script to the sample workbook and try the sample yourself!
26+
2227
```TypeScript
2328
function main(workbook: ExcelScript.Workbook) {
2429

docs/resources/samples/remove-hyperlinks-from-cells.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ ms.localizationpriority: medium
1212
> [!NOTE]
1313
> This only works if the cell count is < 10k.
1414
15-
## Sample Excel file
15+
## Setup: Sample Excel file
1616

17-
Download the file [remove-hyperlinks.xlsx](remove-hyperlinks.xlsx) for a ready-to-use workbook. Add the following script to try the sample yourself!
17+
This workbook contains the data, objects, and formatting expected by the script.
18+
19+
> [!div class="nextstepaction"]
20+
> [Download the sample workbook](remove-hyperlinks.xlsx)
1821
1922
## Sample code: Remove hyperlinks
2023

24+
Add the following script to the sample workbook and try the sample yourself!
25+
2126
```TypeScript
2227
function main(workbook: ExcelScript.Workbook, sheetName: string = 'Sheet1') {
2328
// Get the active worksheet.

docs/resources/samples/report-day-to-day-changes.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ ms.localizationpriority: medium
99

1010
Power Automate and Office Scripts combine to handle repetitive tasks for you. In this sample, you're tasked with recording a single numerical reading in a workbook every day and reporting the change since yesterday. You'll build a flow to get that reading, log it in the workbook, and report the change through an email.
1111

12-
## Sample Excel file
12+
## Setup: Sample Excel file
1313

14-
Download [daily-readings.xlsx](daily-readings.xlsx) for a ready-to-use workbook. Add the following script to try the sample yourself!
14+
This workbook contains the data, objects, and formatting expected by the script.
15+
16+
> [!div class="nextstepaction"]
17+
> [Download the sample workbook](daily-readings.xlsx)
1518
1619
## Sample code: Record and report daily readings
1720

21+
Add the following script to the sample workbook and try the sample yourself!
22+
1823
```TypeScript
1924
function main(workbook: ExcelScript.Workbook, newData: string): string {
2025
// Get the table by its name.

0 commit comments

Comments
 (0)