[FileSaver - Blob] The data parameter must be a valid blob object

My current issue involves utilizing angular-file-saver to export a table into an xlsx file. The table is contained within a div specified by $document[0].getElementById('exportable').innerHTML.

To achieve this, I am creating a Blob object which is then passed as a parameter to FileSaver.

vm.blobData = new Blob([$document[0].getElementById('exportable').innerHTML], {
    type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  });
var config = {
    data: vm.blobData,
    filename: vm.scoreboardtype + 'scoreboard' + vm.scoreboarddate + '.xls'
  };
FileSaver.saveAs(config);

However, upon executing the code, I encounter the following error message: "Data argument should be a blob instance".

Is there a solution you can provide for this issue?

Thank you,

Answer №1

Great news! The issue has been resolved. Now the FileSaver.saveAs(..) function accepts parameters.

FileSaver.saveAs(config.data, vm.scoreboardtype + 'scoreboard' + vm.scoreboarddate + '.xls');

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

Combining pdfmake with AngularJS and Electron results in the generation of a new PDF document

I am having an issue with integrating the pdfmake library into my AngularJS and Electron project. The PDF generated appears blank. Here is the code snippet: .service('PDFService', function() { this.createPdfOne = function(data) { ...

CSS rule for elements in a disabled state

Currently, I am utilizing AngularJS to manage the enabling and disabling of image buttons. Despite my attempts to use a CSS selector to display them as transparent once disabled, it is not working as expected. While testing with a provided example that app ...

Injecting $modalInstance manually at a later point in the controller

Using angular UI bootstrap, I am trying to reuse a controller from a modal dialog in a non-dialog view. After attempting to manually retrieve the $modalInstance using $injector.get('$modalInstance'), I found that it did not work ($injector.has(& ...

A more cost-effective method to replicate an image multiple times using Angular

In the productivity tool I've created, there is a daily log of pomodoros completed. Each day's progress is displayed on a timeline with a tomato icon representing each pomodoro. To achieve this visual representation, I am using AngularJS directiv ...

What makes `Why await` stand out from all the other broken promises?

I am puzzled by the behavior of promises in Node.js and I have a question about it. Let's take a look at the following function as an example: async function proc(): Promise<void> { const resolve = new Promise((resolve) => setTimeout(resolv ...

How can I structure the response from HttpClient to make it compatible with *ngFor

I need assistance in solving a minor issue. I am working with data from a REST API, which is returned as an array of objects. After receiving this data in my service, I attempt to transform it and push it to a subject to notify my component about the arriv ...

Looking for an uncomplicated SSO system similar to Google Identity Toolkit but with a customizable UI interface?

I'm really impressed with the Google Identity Toolkit, it's so user-friendly and easy to set up! However, I'm having trouble with the fact that it forces me to use its UI. Is there another option available that will allow visitors to simply ...

How can a string be transformed into a JavaScript Object without using JSON?

I have a good grasp on parsing a valid JSON string using JSON.parse('{"key" : "value"}'). But what happens when dealing with a valid JS object, but invalid JSON, such as: JSON.parse("{ key : 'value'}")? The outcome of this example is a ...

Issue with finding module in TypeScript component import during Jest test

Despite having the correct path to my styled objects, I'm puzzled by the error message that has popped up: Error: Cannot find module '../../shared/models' from 'Astronaut.tsx' import { moonHoldings } from '../../shared/models ...

Issue with object transformation causing clipping problem in Three.JS

I am currently working on an extension object clipping with 6 planes. The constant of the plane is being controlled by 3 scroll bars, which can be seen below: [ https://i.sstatic.net/eHFho.png The original clippingPlanes are as follows: var localPlane_x ...

What is the best way to trigger a function with a bootstrap toggle?

A toggle switch has been implemented using bootstrap with the following code snippet: <label > Automatic Refresh: </label> <input class="pull-right" data-size="mini" type="checkbox" data- toggle="toggle"> When the toggle button is in ...

The use of callbacks is ineffective in addressing the asynchronous nature of

Hello everyone, I'm currently working on a weather app and I'm facing an issue with the asynchronous behavior of useState. I've come across some suggestions on Stack Overflow that using a callback in the useState function might solve the pro ...

Experiencing issues while trying to publish on Cloudflare Workers?

To organize my project, I decided to create a folder named workers. Inside this folder, I followed these steps: Firstly, I initiated the project using npm init. Next, I installed @cloudflare/wrangler by running npm i @cloudflare/wrangler. This action resul ...

Which function is triggered first - onclick or ng-click?

Currently, I have a button with a validation process occurring on click. The validation process triggers a web service call and other processes if successful. However, I'm uncertain if the validation is actually taking place. This is my page setup: ...

Node.js expressing caution about the use of backslashes in console logging statements

While this issue may not be considered crucial, I have observed an unexpected behavior when it comes to logging backslashes to the console. To verify the results, please try the following two examples in your terminal. I experimented with versions 0.10 an ...

Use jQuery's `append` function only if it is

What is the best way to append only if a telephone number exists and skip if a telephone number does not exist? for (var i in data.businesses) { if (data.businesses[i].telephone) { $('body').append( "<p>" + data.businesses[i]. ...

using node.js to extract a cookie from a 302 redirect

Need help simulating a login using node.js. The request is a post method and returns a 302 status code. However, when trying to simulate the request in node, I encounter the following error: Error handling unrejected promise: StatusCodeError: 302 Upon i ...

React component attempts to display content before receiving data from API_FETCH, causing rendering issues

I have encountered an issue while fetching data from a crypto API that provides data for 250 coins. Everything works fine when I retrieve data for only 100 coins. However, when I attempt to load data for all 250 coins, the data gets rendered prematurely an ...

Can the value of a variable be passed as seen in the JavaScript code snippet?

I'm wondering if I'm on the right track with generating random colors when a button is clicked. Here's my code: randomColor = "#" + Math.floor(Math.random() * 16777215).toString(16); // --- more code --- changeHeaderColor() { con ...

Unleashing the potential of an endless animation by incorporating pauses between each iteration

I am trying to create an infinite animation using animate css but I want to add a delay between each iteration. After exploring various options, I first attempted to achieve this using plain JavaScript. Here is the HTML snippet: <div id="item" class= ...