Using JavaScript, reload the page once the data has been retrieved from an Excel spreadsheet

I'm facing an issue with my JavaScript code. Here's what I have:

                a = Excel.Workbooks.open("C:/work/ind12.xls").ActiveSheet.Cells.find("value");
                if(a == null)
                    document.getElementById('dateValid').innerText = "Date not Valid";
                    Excel.close();

The code is connecting to my Excel sheet and finding a specific value, which works perfectly fine. However, after it's done, the page refreshes and all the values in text boxes and other elements are lost. Is there any way to prevent the page from refreshing or retain my values?

Thank you.

Answer №1

Here is an example to try:

 let Excel;
        Excel = new ActiveXObject("Excel.Application"); 
        Excel.Visible = false;
        let data = Excel.Workbooks.Open("C:/Documents and Settings/Desktop/word/TEST.xls").ActiveSheet.Cells(1,1).Value;
         if(!data)
        document.getElementById('dateValid').innerText= "Date is not valid";

        Excel.Quit();

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

What is the best way to produce a random integer within the range of 0 and 2

Here is the code snippet: var i = prompt('Please choose Rock, Paper or Scissors:'); var b = ['Rock', 'Paper', 'Scissors']; Now, I need help in generating a random number between 0-2. My initial idea was to do t ...

Attempting to insert a square-shaped div within a larger square-shaped div and enable it to be moved around by dragging

Imagine this scenario: I have a button and a large div. When the button is clicked, the code adds a new div inside the larger one. However, the new div is not draggable because I didn't implement the necessary code. I'm also trying to figure out ...

Repeat the execution or refresh an EventListener

I am a beginner in the world of coding, currently working on my inaugural project to create a web-based game using HTML, CSS, and JavaScript. I have encountered an issue with the .addEventListener() method that I couldn't seem to find a solution for ( ...

"Utilizing d3 to parse and track variables within JSON data

To calculate the number of occurrences of s1, s2, and s0 in JSON data and use this information to plot a multiline chart with date (path of date is as follows reviews_details>>variable vf of JSON) on the X-axis versus the number of reviews (s1/s0/s2 ...

What is the best way to stop this Jquery slider from moving?

I've been struggling with this issue for what feels like forever, and it's driving me crazy! I have a slider on the homepage that I'm trying to enhance with a "click to pause" feature (and maybe even a click to resume, for good measure). I ...

Steps for signing up for an event using addEventSource in fullCalendar

Whenever I click on the dayClick event, my goal is to add an event to the date that was clicked. This is the JavaScript code I currently have: $('#calendar').fullCalendar({ header: { center: "title", // The title appears in the center ...

When the text in a Material UI Textfield is updated using setState in React, the Hinttext may overlap with the newly set

How can I fix the issue of default hintText and floatingLabelText overlapping with text in a textfield when using setState to autofill the textfield upon clicking on an edit button? Here is an image showing the textfield overlap: https://i.sstatic.net/8M ...

audio enhancement in a web-based game

I'm having trouble getting a sound effect to play consistently in my game whenever there is a hit. Sometimes the sound plays, other times it does not! Here is the code I am using: <script> var hitSound = new Audio(); function playEffectSound ...

Error message HMR Webpack was found to be invalid

When using Webpack, I keep encountering the following error message: Invalid HMR message, along with a lengthy JSON string. Unfortunately, I couldn't find any helpful resources to assist me in debugging this issue. Do you have any suggestions? https ...

Modify path and refresh display upon ajax call to node server

Recently, I made the decision to utilize a Node server as a proxy for making API calls to third-party public APIs from my front end. After successfully sending a request to my Node endpoint and then to the third-party API, I received the expected response. ...

An error occurred while trying to access properties of null during a promise, specifically when trying to read the 'parentNode' property - triggered by calling router.push({})

After updating my dependencies, I encountered an issue every time I clicked on a button to navigate to the next page. The error message Uncaught (in promise) TypeError: Cannot read properties of null (reading 'parentNode') would appear, even thou ...

Trouble with Fetching Data by ID in MongoDB 2.0.0 Driver

In my NodeJS/Express web service project, I am using the MongoDB 2.0.0 driver to interact with the database. UPDATE: Following previous feedback, I have made changes to my code, including removing the db.close() call. Everything works smoothly when I per ...

jPlayer - Utilize the setMedia() function to define the media source URL

Having some trouble using jPlayer on Firefox 3.6 (Ubuntu) function loadmedia() { $('#jquery_jplayer_1').jPlayer('setMedia', { mp3: 'media/audio/04-Piste_4_1.mp3', }); } $(document).ready(function () { $('#jque ...

Exploring the power of Nestjs EventEmitter Module in combination with Serverless functions through the implementation of Async

I am working on implementing an asynchronous worker using a serverless lambda function with the assistance of the nestjs EventEmitter module. The handler is being triggered when an event is emitted, but the function closes before the async/await call. I ...

javascript: obtain the height of the pseudo :before element

Can someone help me figure out how to get the height of a pseudo :before element? I've tried using jQuery but it's not working as expected. Here's what I attempted: $('.test:before').height() // --> null If you want to take a ...

Gathering information from a website where the URL remains constant even after clicking on a specific button

Visit this website for bus tickets: I am working on scraping data related to bus trips from the mentioned site. However, the data I need to scrape depends on the user-selected date in my web application. Does anyone have suggestions on how I can develop ...

Is the process.env.NODE_ENV automatically set to 'production'?

While examining someone else's code, I noticed this particular line. if (process.env.NODE_ENV === 'production') { ... The application in question is a node.js app with express server and reactjs front-end. If we were to deploy it on Heroku ...

"Implement a feature to recognize and handle various file extensions within an npm

I need help with my npm script where I am trying to include both ts and tsx file extensions. My current code snippet is as follows: "test": "mocha ..... app/test/**/*.spec.{ts,tsx}" Unfortunately, the above syntax is not working correctly. Can someone pl ...

Maintaining the highlight of the active row in Oracle Apex Classic Report even after the dialog window is closed

Greetings to everyone gathered here! Currently, I am working on a single page in Oracle Apex (version 4.2.6.00.03) that contains two Classic Reports — one serving as the "master" report and the other displaying the corresponding "details". Additionally, ...

Library written in JavaScript for extracting CSS that is relevant

Is there a JavaScript tool available that can extract the style information from HTML code? For instance, when given the following HTML snippet, it would output a style block containing all the computed styles applied to each of those elements? Input... ...