0

This is the first time I write in this place. I was looking for a solution everywhere and I could not find it. I do not know if it can be done or not.

The theme is like this: I have a json where one of the data it contains is an image. I need to export that json to an excel, where each data goes to a cell. Therefore, I need to be able to insert that image into one of the cells.

Is it possible to do this? Keep in mind that it is for a mobile app offline, so it should be in javascript and client side.

Many thanks! Greetings.

Lucas
  • 1
  • 1
  • 1
  • The code basically iterates a json. For each iteration, you should generate a new row in excel. In that row, a field is an image. The question is how do I make that image look in excel. – Lucas May 12 '17 at 17:37

1 Answers1

0

There is a JS library to create excel. I haven't tried it though. https://github.com/stephenliberty/excel-builder.js However, it should be fairly trivial to loop through your JSON and create a CSV file, which will ultimately open in excel. That might work better depending on your needs.

But to be clear, when you say holds an image, do you mean a link to an image, or a base64 text of an image? The latter would be huge and probably break excel in some way.

Trevor
  • 2,792
  • 1
  • 30
  • 43
  • My application works completely offline. Therefore, I could not have a link to an image. The image is text in base64. My question is how do I do in Excel to see an image in base 64. Because now I can only see the text in the cell. – Lucas May 12 '17 at 17:30
  • Oh, funny I am doing the exact same thing for a cordova app right now. I am reading this guide. http://ourcodeworld.com/articles/read/150/how-to-create-an-image-file-from-a-base64-string-on-the-device-with-cordova Maybe it will help you? The other way I read was to put the image to a canvas, then get back the blob, which can then be written to a file. I can't post code though because I haven't actually done it yet, just reading about it. – Trevor May 12 '17 at 18:12
  • But can a blob image be inserted into an excel cell? – Lucas May 12 '17 at 18:40
  • Not directly. You'd have to save it to a file, then do this. http://stackoverflow.com/questions/12936646/how-to-insert-a-picture-into-excel-at-a-specified-cell-position-with-vba If you have access to add macros to the excel file, you can make this a lot easier on yourself. Then you just use an excel template with macros. – Trevor May 12 '17 at 18:56