Utilize JavaScript API to style cells within an embedded Excel spreadsheet

Does a JavaScript API exist for formatting cells within an embedded excel file? Currently, we are using the EWS DOM API to format cells, but it has proven to be unstable and dependent on the browser.

Answer №1

Absolutely possible! Here are a few examples to illustrate.

function CustomizeTable() {
    var tableData = new Office.TableData();
    Office.select("bindings#MyTableXXX").setFormatsAsync(
                [

                //Define formatting for row 1
                { cells: { row: 0, column: 2 }, format: { alignHorizontal: "right", fontSize: 15 } },

                //Formatting for row 2
                { cells: { row: 1, column: 0 }, format: { numberFormat: "dd-mmm-yy", fontStyle: "bold" } }, 
                { cells: { row: 1, column: 1 }, format: { fontColor: "red", fontStyle: "bold", numberFormat: "#,###.00", borderColor: "blue" } },

                //Adjusting height of row 3
                { cells: { row: 2 }, format: { height: 30 } },

                //Applying border style to the entire table
                { cells: Office.Table.All, format: { borderStyle: "dotted" } },

                ],
        function (asyncResult) {

            //Handle success or error message
            if (asyncResult.status === "failed") {
                writeToPage('Error in applying formats: ' + asyncResult.error.message, 3);
            }
            else {
                writeToPage('Table cell formats successfully applied', 1);
            }
        });
}

For further details, visit www.microsoft-office-add-ins-guide.com

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for identifying functions that return objects

I'm trying to figure out how to extract the type from the object returned by a specific function. The function returns an object with two keys: X and Y. In my getItem function, I only need the type of X. I don't want to use the interface Selecte ...

When using CSS float:left and overflow:visible, the text may get cropped-off at

I'm currently experimenting with creating a color gradient in javascript using numerical values within some of the divs to indicate scale. However, I've run into an issue where as the values get larger, they are cut off due to the float:left prop ...

dojo combobox with data loaded dynamically from JSON

I am facing an issue with populating a Combobox dynamically using a jsonRest from a cross-origin request. While I have managed to do it statically (if that's the correct term), I am struggling to implement it for multiple cases. This is just a small ...

Using AJAX and Spring MVC to render JSON objects in bracket notation within a POST request

Why is a JSON rendered in bracket notation when bound to a Web Request? I am working on an application that involves making 2 consecutive REST Controller calls. The first call reads an address from a form, serializes it, sends it via AJAX to a validation ...

"Utilize JavaScript to extract data from JSON and dynamically generate a

I'm currently facing an issue with reading JSON data and populating it in my HTML table. The function to load the JSON data is not working as expected, although the data typing function is functioning properly. I have shared my complete HTML code alo ...

enhancing the style of my Express project with CSS and EJS

Currently, I am facing challenges with linking CSS to my EJS files in a project I am developing using Node/Express/EJS. Despite creating a public folder with a CSS subfolder and the main.css file inside, I am unable to get the CSS to display in the browser ...

Searching for a value within an array of objects using JavaScript: The ultimate guide

Similar Question: Locate specific object by id within a JavaScript objects array What is the best way to determine if a value exists in a given JavaScript array? For instance: var arr = [ {id: 1, color: 'blue'}, {id: 2, colo ...

Node.js: The object in req is not functioning as expected

// Function to merge objects with unsent columns kept from old objects. function merge_options(obj1, obj2) { const obj3 = {}; for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; } for (var attrname in obj2) { obj3[attrname] = obj2[attrname] ...

Switching over to the latest version of Material-UI, v1.x.x

Currently, my app relies on Material-UI v0.17.0 which is not compatible with React v16.0.0. In order to make it work, I need to upgrade to Material-UI v1.0.0. I came across a migration tool here, but it only updates import statements. Many props have chan ...

Having trouble retrieving values from my EXPRESS / NodeJs response error message: [String: 'Error: Request resulted in an error code: 404'

I have been attempting to retrieve values from my express response error. When I use console.log on the error like so... app.use(function(err, req, res, next){ console.log(err) }); The content displayed in the console is as follows: [String: 'E ...

Place a user input field within a div element having the specified class

I am trying to insert an HTML input element into the following div: <div class="sss" style="padding-top:2px"> <center> <input value="test1" name="name1" type="submit" > <input value="test2" name="name2" type="submit"> </c ...

handsontable - personalized HTML button placed at the beginning of each row that performs an action when clicked

In my handsontable, I have successfully added a custom button in the 2nd column. When this button is clicked, I want to send the data of that particular row to the server for processing. I have written an onClick function for the button, but I am struggli ...

How to dynamically set a computed background image in Vue 2

I have several divs that I want to style with backgrounds from values stored in an array. My attempt to set the background overlay for each one by creating a computed property has not been successful: computed: { backgroundImage(url) { let ...

Refreshing a div by replacing its content with text entered into an input field

I'm exploring React and attempting to create a basic div that dynamically changes its text based on input from an input box. Below is the code I have written so far: import React from "react"; import ReactDOM from "react-dom"; const rootElement = d ...

Every time I attempt to reuse my components, they keep piling up on top of each other

I'm facing an issue where I need to reuse components I've created multiple times while rendering dynamic content. However, when I attempt to render them, they end up stacking on top of each other in the same position. Each time I render ...

Testing network connection using alert feature in Ionic 2

Looking to verify network connectivity with an alert in Ionic 2. While this guide was helpful, it is quite outdated now and Ionic 2 syntax has evolved. Despite modifying the Alert component as suggested in the comments, I'm still encountering errors. ...

Troubleshooting Vee-validate scope issues in Nuxt.js and Vuetify

I'm experiencing an issue with validation using vee-validate and Vuetify: I have two forms with different scopes, both being submitted within one function. While the validation is functioning correctly upon submission, the input errors are not displa ...

Is it possible to retrieve all data from the Google translation API?

In my React app, the main component contains this function: componentDidMount(){ const land = ["Afrikaans", "Albanian", "Amharic", "Arabic", "Armenian", "Assamese", "Aymara", &qu ...

Auto-complete feature for JQuery selectors in Netbeans

For some time, I struggled with getting Netbeans to automatically complete my selectors for JQuery. Here's an example: <a id="hello" href="#">Hello</a> <script type="text/javascript"> $("|").hide(); </script> According to ...

Unable to verify the provided resource: Mailchimp

Welcome everyone to my first question posted on StackOverflow. I have tried my best to provide all the necessary details regarding the issue in order to seek assistance. If you require additional information, feel free to ask. To give a brief overview, I ...