none
Office.CoercionType.Image for Excel returns enumeration unsupported RRS feed

  • Question

  • I understand from the javascript api docs that I should be able to insert an image in an excel sheet. 

    However, I get 'the enumeration isnt supported in the current host application' when i do this

          Office.context.document.setSelectedDataAsync (png, {
            coercionType:Office.CoercionType.Image,
            imageLeft:offx ,
            imageRight:offy 
          } ....

    I'm running this as an Excel sidebar, my data is an encoded image that starts like this data:image/png;base64,iVBORw0KGgoAAAANSUhE....

    My expectation is that this will image will be inserted at the active cell, with the gicen offset.

    Have I misunderstood something? 

    Btw I'm unning this on excel online, and this is false

    Office.context.requirements.isSetSupported('ImageCorecion','1.1')


    bruce mcpherson



    Saturday, June 11, 2016 12:57 PM

Answers

  • Hi Edward

    The sample project in VS show ImageCoercion is supported (at least it does when run from VS). The sample from Yeoman says it's not. If I copy the manifest from VS to the YO sample project, it still doesn't work - so there is something else in the VS studio environment other than the manifest that is not replicated in YO, but I have no idea where to look.

    I don't really want to get involved in now converting everything over to Visual studio. It's way too complicated for this simple problem, and I won't be able to keep multiple dev environments in sync ongoing.

    I've raised an issue on github for this .. presumably that's the correct place?

    thanks for your help.

    Bruce


    bruce mcpherson

    Wednesday, June 15, 2016 9:56 AM

All replies

  • Hi bruce,

    What is your VS version? Have you used Office add in 1.1? If not, I suggest you refer Update the version of your JavaScript API for Office and manifest schema files for how to update version of javascript api.

    In addition, if you test your add in in Excel deaktop, will this issue still exist?

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, June 13, 2016 6:50 AM
  • Edward

    Thanks for looking at this for me. 

    Im not using visual studio - I'm using visual studio code for editing, and built the original manifest with the yeoman tools. However I am using 1.1 as far as the manifest is concerned

    xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"

    and checking the version of Office.js that is loaded with

    https://appsforoffice.microsoft.com/lib/1/hosted/Office.js

    it is the same one as 

    https://appsforoffice.microsoft.com/lib/1.1/hosted/Office.js

    I'm using other stuff that (I think) was introduced in 1.1 such as Excel.run. Btw I saw a video on 1.2 the other day but there is not hosted version of 1.2 available as far as I can find.

    I get the same result when I run the thing locally using Excel 2016. (although I have  a few different problems popped up there).

    I'm porting a working add-on from Google Apps Script http://ramblings.mcpher.com/Home/excelquirks/addons/sankeyaddon

    This is my first attempt at Office add-ins, and I'm finding the environment a little alien, so I may be missing something fundamental 

    thank you again


    bruce mcpherson

    Monday, June 13, 2016 9:52 AM
  • Hi bruce,

    How did you create Office add in with yeoman? Did you follow the steps below:

    #Creating Office Add-ins with any editor - Introducing YO OFFICE!

    https://dev.office.com/blogs/creating-office-add-ins-with-any-editor-introducing-yo-office

    >>I get 'the enumeration isnt supported in the current host application

    With other CoercionType like Text, will your add in works correctly?

    >>I'm porting a working add-on from Google Apps

    What is the relationship between your addin and Google apps? To narrow down this issue, I suggest you create a simple Office add in to check whether it will work, test setSelectedDataAsync with Text, and test setSelectedDataAsync Image.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, June 14, 2016 6:31 AM
  • Hi Edward

    >> Yo Office

    Yes I did this. I took the minimal app option, since I already have most of the source code and I didn;t need a full blown app. For a test, I've just created the standard starter sample app with yeoman, this time creating a full blown html/js/css app option.

    Using the created app, I inserted this code to see what's supported

            ['TextBindings','TextCoercion','TableCoercion','TableBindings','Settings',
            'MatrixBindings','MatrixCoercion','ImageCoercion','DocumentEvents',
            'BindingEvents','ExcelApi'].forEach(function (d) {
              console.log(d+':'+Office.context.requirements.isSetSupported(d,'1.1'));
            });

    The result is this when i run it on office online - image coercion is unsupported

    TextBindings:true
    TextCoercion:true
    TableCoercion:true
    TableBindings:true
    Settings:true
    MatrixBindings:true
    MatrixCoercion:true
    ImageCoercion:false
    DocumentEvents:true
    BindingEvents:true
    ExcelApi:true

    >> Other coercion types. 

    I tried the same code in my app, and got exactly the same results (everything supported except imagecoercion)

    I also tried adding this to the manifest, and it wouldn't install.

      <Requirements>
        <Sets DefaultMinVersion="1.1">
          <Set Name="ImageCoercion" MinVersion="1.1"/>
       </Sets>
       <Methods>
          <Method Name="Document.getSelectedDataAsync"/>
       </Methods>
    </Requirements>

    >> google apps

    The app is ported from Google Apps, but the API specific piece is replaced with code to talk to the office API. See my previous answer on simplified app. The yeoman generated sample app has the same symptoms, straight out of the box.

    regards

    Bruce


    bruce mcpherson

    Tuesday, June 14, 2016 10:04 AM
  •  > data  Type: String, Array (array of arrays - "matrix"), TableData, HTML (Word only), or Office Open XML (Word only)
    http://msdn.microsoft.com/en-us/library/fp142145.aspx
    Tuesday, June 14, 2016 10:27 AM
  • Ajit

    Further down the same article, it says that Excel supports image coercion.

    • Base64 encoded image stream (Office.CoercionType.Image) - Applies to Excel, PowerPoint, Word and Word Online only.

    Bruce


    bruce mcpherson

    Tuesday, June 14, 2016 10:35 AM
  • Hi bruce,

    It is really amazing only ImageCoercion is not supported. I suggest you test your code in VS 2015 with template in VS 2015 to check whether it is related with Yeoman. If it works in VS2015, I suggest you use Yeoman to open the project to check whether it will work or not.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, June 15, 2016 8:04 AM
  • Hi Edward

    The sample project in VS show ImageCoercion is supported (at least it does when run from VS). The sample from Yeoman says it's not. If I copy the manifest from VS to the YO sample project, it still doesn't work - so there is something else in the VS studio environment other than the manifest that is not replicated in YO, but I have no idea where to look.

    I don't really want to get involved in now converting everything over to Visual studio. It's way too complicated for this simple problem, and I won't be able to keep multiple dev environments in sync ongoing.

    I've raised an issue on github for this .. presumably that's the correct place?

    thanks for your help.

    Bruce


    bruce mcpherson

    Wednesday, June 15, 2016 9:56 AM
  • Hi Bruce,

    Thanks for testing result. I agree with you, it seems there is something wrong in YO, I think GitHub is correct place.

    If you have any updates about this issue, it would be appreciated if you could share us.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, June 15, 2016 11:45 AM
  • Raised as an issue on GitHub. here

    bruce mcpherson


    Wednesday, June 15, 2016 4:31 PM
  • Well, they finally got round to closing this issue. https://github.com/OfficeDev/office-js-docs/issues/289 Their conclusion is that image coercion is actually not supported in excel, and they will update the documentation to reflect that.

    bruce mcpherson

    Saturday, January 21, 2017 10:59 PM