GithubHelp home page GithubHelp logo

zlatkovsky / buildingofficeaddins Goto Github PK

View Code? Open in Web Editor NEW
13.0 7.0 5.0 56 KB

Issues & topic-request tracker, and sample-code repository, for "Building Office Add-ins using Office.js"

Home Page: http://buildingofficeaddins.com

License: MIT License

buildingofficeaddins's Introduction

Building Office Add-ins using Office.js

The everygreen book

This repo is a sample-code and issue-tracking companion to the book "Building Office Add-ins using Office.js" -- an "evergreen" e-book published and purchasable through LeanPub.com.

From the book description:

This book is a guide to Office.js APIs, which are used to build the web-technology-based Office Add-ins. Is describes the principles and design patterns shared by the new 2016+ wave of APIs for Excel, Word, and OneNote -- written by someone who, as member of the Office Extensibility Platform team at Microsoft, had helped design them.

 

This repo's purpose is to:

#1: Allow me to share the larger code samples and associated assets (e.g., documents with sample data, geared specifically for the scenario).

#2: Provides readers with a way to log and track content issues (and be informed once they are fixed). Issues can be:

  • Simple content issues: A misspelling, an incomplete phrase, a sentence that no longer makes sense.
  • Requests for additional detail in existing topics.
  • Requests for brand new topics. I might already be planning to write something about it eventually, but this will let you subscribe to finding out when the content is made available; and will also help me gauge topic interest.
  • Issues with sample code or related assets: code is unclear; the design is sub optimal; something needs a comment; or perhaps an existing comment needs to be clarified or removed.
  • Anything else?

#3: Keep track of the Release notes.

 

If you have questions about specific APIs, please use StackOverflow.

This repo is meant for aggregating book issues -- but the book's purpose is not to cover every single API, but rather to cover the common concepts. If you have a question about a specific API, please use StackOverflow, tagging your question office-js.

In fact, even if your question is about a core concept, I still encourage you to ask it on StackOverflow first, as you'll almost certainly get a quicker response there (and if the response is from me, it might well make it into the book eventually!). This repo is for tracking the issues and topics, but addressing questions is best done through StackOverflow.

If you want to contact me, please feel free to reach out at

buildingofficeaddins's People

Contributors

zlatkovsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

buildingofficeaddins's Issues

Suggestion -- 4.2.2 Variables & TypeScript

Maybe a screenshot? Would help to explain/show the below:

Parameter type declarations. This is supremely useful, as it allows
you to split long procedures into multiple subroutines, and yet not
lose IntelliSense and compile-time error-checking. For example,
you can declare a function as
function updateValues(range: Excel.Range) { ... }
and be able to see all of the range properties/methods/etc. within the
body of the function, as opposed to seeing a dishearteningly-empty
IntelliSense list.

Req sets: add info about defined OM

In environments that don't support tables: var tables = context.document.body.tables; the above tables var is defined. It just errors on load.

Stocks Example

The REST query to yahoo does is not working out-of-the-box. Changed the URL as follows to get it to work. FYI.

    var data = 'q=' +
        encodeURIComponent(
            'select * from yahoo.finance.quote ' +
            'where symbol in (' + quotedCommaSeparatedNames + ')'
        ) +
        "&env=store%3A%2F%2Fdatatables.org" +
        "%2Falltableswithkeys&format=json";

Concrete Excel example: 4 ways to compute sum of range

try {
    await Excel.run(async (context) => {
        var array = [
            [0, 1, 1, 1],
            [0, 0, 1, 0],
            [0, 0, 1, 0],
        ];

        // Method 1 (write formula and read back)
        // const sheet = context.workbook.worksheets.getActiveWorksheet();
        // const range = sheet.getRange("A1").getResizedRange(array.length - 1, array[0].length - 1)
        // range.values = array;
        // const sumRange = sheet.getRange("F2");
        // sumRange.formulas = [["=SUM(A1:D5)"]]
        // sumRange.load("values")
        // await context.sync();
        // OfficeHelpers.UI.notify("Sum", sumRange.values[0][0].toString())

        // Method 2 (use Excel as calculation engine)
        // const sheet = context.workbook.worksheets.getActiveWorksheet();
        // const range = sheet.getRange("A1").getResizedRange(array.length - 1, array[0].length - 1)
        // range.values = array;
        // const sum = context.workbook.functions.sum(range).load("value")
        // await context.sync();
        // OfficeHelpers.UI.notify("Sum", sum.value.toString());

        // Method 3: (calculate in-place via plain JS)
        // let sum = 0;
        // array.forEach(row => {
        //     row.forEach(cell => {
        //         sum = sum + cell;
        //     });
        // })
        // console.log(sum)

        // Method 3B:
        // let sum = 0;
        // array.forEach(row => row.forEach(cell => sum = sum + cell))
        // console.log(sum)
    });
}
catch (error) {
    OfficeHelpers.UI.notify(error);
    OfficeHelpers.Utilities.log(error);
}

[Content issue]: Incorrect statement in "Implementation Details" section

In this section, you say that when a method or property gets called on a proxy, either an object path is created or an action, but that is not correct. All property access and method call create a new action, which operates on a object and may or may not create another object, which would then get assigned its object path.

Event handlers

[Please describe the issue here]

[Optional] Add a screenshot or a description of text before/after. (Page numbers and section numbers change all the time, and so aren't useful as reference points)

Fix example code from page 99

The correct would be:

function createRainbow() {
	var $rainbow = $("#rainbow");
	$rainbow.css("background", "red");
	setTimeout(function() {
		$rainbow.css("background", "orange");
		setTimeout(function() {
			$rainbow.css("background", "yellow");
			setTimeout(function() {
				$rainbow.css("background", "green");
				setTimeout(function() {
					$rainbow.css("background", "blue");
					setTimeout(function() {
						$rainbow.css("background", "indigo");
						setTimeout(function() {
							$rainbow.css("background", "violet");
						}, 2000);
					}, 2000);
				}, 2000);
			}, 2000);
		}, 2000);
	}, 2000);
}

Obs. 1: Sorry for changing ' to ", it is my linter.
Obs. 2: Maybe it is easier to change just var $rainbow = ... to var object = ..., as the very same error happens in pages 101 and 102, but a good jQuery script is to put $ as a prefix in jQuery variable names.

Add topic on npm, vs code

[Please describe the issue here]

[Optional] Add a screenshot or a description of text before/after. (Page numbers and section numbers change all the time, and so aren't useful as reference points)

Trivial typos: 4.2.2 Variables & TypeScript

Typo:

  1. ...it is always a best-practice to use “let“. In fact, if you’re only assigning
    a variable once and never re-assinging it, it is better to use an event
    stronger form of let: “const”....

should be: ..re-assigning it, it is better to use an even....

  1. Very occasionally, you might have disagreement with the TypeScript
    compiler over a particular type. This happens primarily in Excel for 2Darray
    properties, such as values or formulas on an Excel.Range vobject.

should be: ...Excel.Range object.

  1. Strings can be either be single-quoted or double-quoted, so long as the
    quote types match.

issue: extra "be"

Type in page 101

Armed with this newly-created function for creating Promsies
solve the rainbow scenario much more satisfactorily:

It should be Promises.

Office versions -- clarify that Office 365 is software + services

Office 365 is the brand name Microsoft uses for a group of software and services subscriptions, which together provide productivity software and related services to subscribers. For consumers, the service allows the use of Microsoft Office apps on Windows and macOS, provides storage space on Microsoft's cloud storage service OneDrive, and grants 60 Skype minutes per month. For business users, Office 365 offers service plans providing e-mail and social networking services through hosted versions of Exchange Server, Skype for Business Server, SharePoint and Office Online, integration with Yammer, as well as access to the Microsoft Office software.

https://en.wikipedia.org/wiki/Office_365

Generalize the section “Loading on methods versus properties”

You have a nice section “Loading on methods versus properties”. But the detailed example and solution give the impression that the problem only arises when the developer calls the same method twice, once before and once after the context.sync. I just discovered, the hard way, that the problem is more general than that. For example, the following code will get the error, even though the method settings.getItem method is only called after the context.sync. I suggest that you emphasize in the section that it doesn’t matter how the objects are loaded, when you use a method, you’re getting a brand new, unloaded, proxy object.

var settings = context.document.settings;
settings.add('startMonth', { month: 'March', year: 1998 });
settings.load('value');
return context.sync().then(function () {
	for (var i = 0; i < settings.items.length; i++) {

			// The next line works, so it’s natural for the developer to think that he’s loaded the individual settings.
			console.log(settings.items[i].value);
	}
	// But this line will fail for reasons given in your book.
   var month = settings.getItem('startMonth').value;
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.