Excel Add in - Refresh all custom functions in a specific sheet - office-addins

I am just curious how do I manually refresh all custom functions of my addin in a specific sheet using JavaScript? I have tried to search online through Microsoft docs but could not find any docs mentioning this. Thanks

You can use Worksheet.calculate() API to refresh all custom functions in a specific sheet. The following is an example function.
async function reCalculateSheet() {
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("SampleSheet");
sheet.calculate(false);
await context.sync();
});
}
Besides, I recommend you a Microsoft office add-in “Script Lab” where you can search the sample of the scenario you need and experiment with the Office JavaScript API without ever leaving Excel.

Related

React.js: Best practices for API's grouping

I have been using Angular for 3 years. I have created some small and big projects. In every project, I have used proper folder structure for API calls(which many resources suggest). Below is a simple example
constants.ts
export const uploadData = `${url}/uploadData`;
service.ts
uploadData(formData: FormData): Observable<any> {
return this.http.post<any>(constants.uploadData, formData);
}
And in the component file, I import the service and call the API like this
this.service.uploadData(formData).pipe(take(1)).subscribe((res) => {
// do something
});
I specify all my related APIs and services in respective folders and call them wherever I need them. It's been 5 months since I started learning React and ReactNative. Now I am comfortable with both I started doing a major project. Now, the resources I followed to learn React didn't follow the proper structure(Create the API in whichever folder is required and call it with fetch/axios). Found some resources that follow structure but not effectively like how I did it in Angular. I can't find any resources with the requirement. It would be helpful if I can get one example of how we can have the folder structure like in Angular so that I will follow the good approach, instead of ending up writing bad code. (I am using Axios)

How to create a Google web app using Google Apps Script, React, and MobX

I found react-google-apps-script project on GitHub, and it seems to be able to make my dreams of a React-based Google Apps Script project a reality. For a while, since I learned React (and MobX), I've been wanting to use it inside Google Apps Script projects!
Per the documentation, however, it seems to only work on dialog windows... :'(
That being said, I have a freelancing client who is looking for a UI that can interact with her Google Sheets, to which the most reasonable approach would be to create a web app. I've created Google Apps Script based web apps in the past, in fact it was my very first exposure to it. It seems like they only support raw HTML templates and jQuery .
However, knowing all that I know now, I'd like to create a simple React + MobX MVVM-based web app on the Google Apps Script. How can we use this project to get that done?
UPDATE: I should have read more carefully! This is embarassing!!
From looking at src/server/ui.js, I see that is how the main use case, injecting React project into the modals in Google Apps Script projects that control Google Spreadsheets, even gets to happen.
Here is the code from that file:
export const onOpen = () => {
const menu = SpreadsheetApp.getUi()
.createMenu('My Sample React Project') // edit me!
.addItem('Sheet Editor', 'openDialog')
.addItem('Sheet Editor (Bootstrap)', 'openDialogBootstrap')
.addItem('About me', 'openAboutSidebar');
menu.addToUi();
};
export const openDialog = () => {
const html = HtmlService.createHtmlOutputFromFile('dialog-demo')
.setWidth(600)
.setHeight(600);
SpreadsheetApp.getUi().showModalDialog(html, 'Sheet Editor');
};
export const openDialogBootstrap = () => {
const html = HtmlService.createHtmlOutputFromFile('dialog-demo-bootstrap')
.setWidth(600)
.setHeight(600);
SpreadsheetApp.getUi().showModalDialog(html, 'Sheet Editor (Bootstrap)');
};
export const openAboutSidebar = () => {
const html = HtmlService.createHtmlOutputFromFile('sidebar-about-page');
SpreadsheetApp.getUi().showSidebar(html);
};
It is worth noting that this will transpile to the back-end Google Apps Script code.
This means that we could customize this and make this more general, by editing out the onOpen method. I see it is developer's responsibility to do that :P
Great project! It's easy to follow, and I can see how I can make this my own, with MobX and MVVM!

easy pass data from express to react

So I'm trying to learn ReactJS but the documentation is terrible, after reading it I am even more confused than before.
I will keep it simple for the sake of learning:
This is my old approach:
Current:
app.use(function (req, res, next) {
res.locals.user = req.user || null;
next();
});
So I get it with {user} in handlebars.
Now for react:
{this.props.user}
returns NULL. Seriously, what the ...? How to pass the variable easily?
ReactJS is mostly used for single page applications, meaning that most data is fetched after the application is loaded. If you want to use ReactJS as a template engine with expressJS use express-react-views. Otherwise you need to prerender ReactJS with react-prerender when using NodeJS.
But I guess what you really want to do is to read/watch a good ReactJS tutorial.
Here are some resources for you:
Learn React & Redux
Simple React Development in 2017
Hope that brings you on track :)

AngularFire2 vs Firebase JS

I'm finding the AngularFire2 library to be poorly documented and very hard to use. I have an angular2 app and was wondering if someone could help me clear up the pros/cons of just using the vanilla JS Firebase code rather than angularfire2? Does using the vanilla JS version kill off angular2 functionality that I may be using? I'm confused as to why use one over the other, personally the vanilla JS one is waaaay better documented and feature rich, I can't even see how to Signup Users in AngularFire2, it doesn't have any UI elements and observables are doing my head in!
You can use vanilla version directly. Even with observables - observable and promises work well together. For example:
Observable.of(new firebase.auth.GoogleAuthProvider())
.switchMap(o => firebase.app().auth().signInWithPopup(o))
.subscribe()
Main advantage of AngularFire2 are head-hurting observables (; I suggest you learn rxjs and start using them over promises. I am using vanilla JS SDK, however, I've created refObservable based on what AngularFire2 does with FirebaseObservables. It's simpler, but enough for my needs:
export function refObservable(ref): Observable<firebase.database.DataSnapshot> {
return Observable.create(observer => {
let fn;
try {
fn = ref.on('value', snapshot => {
observer.next(unwrapSnapshot(snapshot));
});
} catch (error) {
observer.error(error);
}
return () => ref.off('value', fn);
});
};
where unwrapSnapshot(snapshot) is simple function that checks snapshot and returns appropriate result (array, object, string, etc...). I use it for reading data from firebase. Create/Update/Delete operations I do directly:
Observable.of(checkUserPermission())
.switchMap(() => {
return firebase.database().ref('what/ever').remove();
});
It's similar with other modules - storage, messaging, auth... I prefer Firebase SDK over AngularFire2. I also find it easier to use in service/web workers.
If you already know vanilla sdk, stick with it.
If you only need database read/write and basic authentication use AngularFire2 it's simpler.
If you need more control over firebase features use JS SDK.

Silverlight Excel Automation Factory API Documentation

Silverlight Excel Automation Factory API Documentation
Hi Im using Excel Automation Factory to export data from silverlight to excel. Problem is I can't find documentation on using excel this way. All I could find where some small tutorial from which i could extract some data
like :
dynamic excel;
excel = AutomationFactory.CreateObject("Excel.Application");
excel.Visible = true;
dynamic workbook = excel.workbooks;
workbook.Add();
but thas all!
Where Can I find Some Excel Automation Factory Documentation?
refer MSDN:- http://msdn.microsoft.com/en-us/library/wss56bz7%28v=VS.100%29.aspx
although there isn't much documentation on same.

Resources