How do I write to excel and have images

0 favourites
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • HI,

    I've been making a pricing tool app for a little while now and pretty happy with how it is working. I am currently using AJAX / a .xml file to open, write values from global variables and saving the app data into a summary table. Trouble is that this means I cannot setup any picture files as these are lost when saving as xml. Does anyone know a workaround?

  • You could store the image files on a server, and have them imported when you run the app.

  • Hi emoaeden,

    Thanks for helping. Would this mean keeping my xml file as it is and then in C2 placing the image into the file?

    At the moment my app has rows of list boxes / text files where you select items, it loads up the prices and it gives a summary on sheet of the totals. When you 'build' it calls a pre setup .xml file from project files and uses the filecontents replace action to export these via a global variable. Would it be at this stage? Or would it still loose the image?

    With my tests / looking online so far I have read that xml cannot save with images hence they disappear when you save. Some sites talk about converting it into base64 code but I was unsure how to implement this.

    Cheers,

  • You are right. What you should do is store the images on a server (let's use dropbox for example). Then have the address in the .XML that calls dropbox.com/user/1234/photos/1.jpg for the first item, dropbox.com/user/1234/photos/2.jpg for the second item, etc

    Then have the app pull/import the image that is at that address.

  • emoaeden

    Thanks, I'll have a look and a play around. If you know any examples that would be helpful. Excel is the output my app makes at the moment so I am hoping for a way that when I send data from my app to the .xml file I can also have a picture in the xml file, suitable to be opened in excel afterwards.

    Thanks,

  • I've still been unable to do this so bumping incase anyone can help.

    Ideally I'd like to save as an .xls file but the methods I know in c2 only let me save to .xlm

    Any help will be greatly appreciated

  • xml is a text format so I don't think you can get excel to load it with images. If you're doing it for your own format you can use something like canvas.asUrl to get a text version of an image that you can load into a sprite or something later, however excel will not understand that.

    You can either figure out how to generate the xls files from the format spec:

    https://msdn.microsoft.com/en-us/librar ... =office.14).aspx

    or maybe use some js library to generate it:

    Maybe this?

    http://excelbuilderjs.com/

  • R0J0hound

    Thanks for the reply. I think the first link is broken but I will look into the second option.

  • Hi,

    So I am still stumped on this one and thought I'd chuck another shout out to see if anyone can help. Sorting images into my excel output is the last part of finishing my 'quote' app and I am hoping it is possible in some manor!

    Thanks,

  • This sound alot like doing impossible things like breathing in space. I have a few question is there a way to make the app store save the image as a file in the host computer file system and then force import it as a file into the app. Through some Ajax fancy magic ? If so then it should it be matter of saving the image file to the host device through its own file system or to force create a folder in their system for your app and then have it save the image to there. Or least that what ive observed from other professionally made app.

  • My trouble is getting the image into an excel output rather than into my app. I think i need to work out of its possible to export data into an .cos file rather than .xml template which is my apps current method.

  • Closer to what you want look at xlsx files. They are zip files of xml files and other things like images.

    You could use something like this to manipulate the zip file from js

    https://stuk.github.io/jszip/

    Then either by looking at the file format spec or disecting some simple xlsx files it should be possible to see how it's done. You could also look at some xlsx JavaScript library but I'm not sure images work with them.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks Looks like some lessons in javascript / C2 pluggin making for me. Shame my programming is as primitive as Spectrum ZX basic!

    10 CLS

    20 Print "Help!"

    30 Goto 20

  • Mayfly

    This is actually a very difficult thing to do.

    Looks like the only js library that can do it is this:

    http://excelbuilderjs.com/

    Here's an example of it's use from C2 with the browser object.

    https://www.dropbox.com/s/t267l8lhl7tsc ... .capx?dl=1

    /examples35/excel.capx

    First it loads the needed libraries and call the "ready" function when it's done.

    Next it creates the workbook, worksheet and populates it from a 2d javascript array.

    Then to get a image to save it snapshots the canvas. You could use the canvas object to get image data as well.

    Finally it generates the file and uses the browser object to download it.

    It basically follows the examples on their site and at the very least gives you a starting point to play around with. Also I won't be making a plugin for this.

  • R0J0hound

    As usual a great help Had a very quick load and play. That's just what I was pretty much after so I'll have a mess about in terms of getting that working how I am after. Should be able to take it from there / integrate into my app. BIG thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)