Skip to content
Permalink
Browse files

Added programmatic color stuff.

  • Loading branch information...
emeryberger committed Mar 28, 2019
1 parent 8703ca1 commit f494585a7e6507167a3ae2f19c33f2e6472f00e5
Showing with 412 additions and 325 deletions.
  1. +12 −0 NOTES
  2. +13 −10 src/components/App.tsx
  3. +387 −315 src/components/colorize.ts
12 NOTES
@@ -2,7 +2,19 @@ Install stuff:

https://docs.microsoft.com/en-us/office/dev/add-ins/quickstarts/excel-quickstart-react

add a certificate:
https://github.com/OfficeDev/generator-office/blob/master/src/docs/ssl.md

Now install stuff:

* With administrative privileges, do this:
npm install -g yo@latest webpack rimraf webpack-dev-server webpack-cli

* Without admin privileges, do this:
npm run build
npm start

Open up Excel Online - office.com

Now click on Insert -> Office Add-ins -> Upload My Add-in (text in upper-right hand side) -> select manifest.xml

@@ -23,7 +23,6 @@ export default class App extends React.Component<AppProps, AppState> {

constructor(props, context) {
super(props, context);
Colorize.initialize();
}


@@ -106,7 +105,7 @@ export default class App extends React.Component<AppProps, AppState> {
} else {
await this.processRange(context, currentWorksheet, startCol, startRow, endCol, endRow);
}
console.log(this.savedColors);
//console.log(this.savedColors);
let endTime = performance.now();
let timeElapsedMS = endTime - startTime;
console.log("Time elapsed (ms) = " + timeElapsedMS);
@@ -121,10 +120,10 @@ export default class App extends React.Component<AppProps, AppState> {
private process(f, currentWorksheet, colorfn) {
// Sort and group by COLUMNS (first dimension).
let grouped_ranges = Colorize.identify_groups(f);
console.log(JSON.stringify(grouped_ranges));
//console.log(JSON.stringify(grouped_ranges));
// console.log(typeof grouped_ranges);
let g = JSON.parse(JSON.stringify(grouped_ranges)); // deep copy
console.log(Colorize.mergeable(g));
//console.log(Colorize.mergeable(g));
// console.log(grouped_ranges);
// FINALLY, process the ranges.
Object.keys(grouped_ranges).forEach(hash => {
@@ -146,6 +145,8 @@ export default class App extends React.Component<AppProps, AppState> {
}

clearColor = async () => {
Colorize.initialize();

try {
await Excel.run(async context => {

@@ -172,6 +173,8 @@ export default class App extends React.Component<AppProps, AppState> {
}

setColor = async () => {
Colorize.initialize();

try {
// OfficeExtension.config.extendedErrorLogging = true;
await Excel.run(async context => {
@@ -213,19 +216,19 @@ export default class App extends React.Component<AppProps, AppState> {
// Make all numbers yellow; this will be the default value for unreferenced data.
numericRanges.format.fill.color = "yellow";

// Give every numeric data item a dashed border.
let items = numericRanges.format.borders.items;
// Give every formula a solid border.
let items = formulaRanges.format.borders.items;
for (let border of items) {
border.set ({ "weight" : "Thin",
"style" : "Dash",
"style" : "Continuous",
"tintAndShade" : -1 });
}

// Give every formula a solid border.
items = formulaRanges.format.borders.items;
// Give every numeric data item a dashed border.
items = numericRanges.format.borders.items;
for (let border of items) {
border.set ({ "weight" : "Thin",
"style" : "Continuous",
"style" : "Dash",
"tintAndShade" : -1 });
}

0 comments on commit f494585

Please sign in to comment.
You can’t perform that action at this time.