Let's follow up this discussion at the Neptune Community

(this forum will be kept in read-only mode)

How to open Word or Excel with OneDrive or iBook on an iPhone

Hi All,

My requirement is to open or view attachments stored in SAP.  For JPG and PDF it's ok i'm using the controls in Neptune made for that and it's perfect.  But when comes time to view .DOCX or XLS or TXT files on an iPhone it does not work.

It works using Chrome (even if a receive an error message from Word saying that the file is corrupted, but that is another story).  

The content received from SAP is base64 encoded for anything else than TXT attachent.  The below convert base64 encoded string into a blob making easier to download.

Here is the javascript code snipet i'm using to download:

function download(content, filename, contentType) {

    if (!contentType) {

        contentType = 'application/octet-stream';


    var a = document.createElement('a');

    if (contentType === "TXT"){

            var blob = new Blob([content], {'type':contentType});

       } else{

            var byteChar = atob(content);

            var byteNumbers = new Array(byteChar.length);

            for (var i = 0; i < byteChar.length; i++){

                byteNumbers[i] = byteChar.charCodeAt(i);


            var byteArray = new Uint8Array(byteNumbers);

            var blob = new Blob([byteArray], {type:contentType})


        a.href = window.URL.createObjectURL(blob);

        a.download = filename;



Thank you all in advance.

1 person has this question

Thanks Pierre.  Nice to hear you are learning Neptune ! :)

Content should be base64 encoded.  Below, I am pasting an example for sending pdf content from the application class.

1 person likes this

Hi Pierre,

Short question from my side:

When you fetch the document data in the SAP backend, are you sending it back to the client with the correct content-type?

Sample code in the Application Class:

"Word Content Type
call method server->api_response_xstring
    data = it_data
    content_type = 'application/vnd.ms-word'.

Thanks and regards,


Hi Julian,

Wow great.  I will try this.  If i'm correct, in this case i don't have to convert it into a base64 string.  I only have to read the content on the backend and transmit it using this method?  Like i said i'm novice in Neptune and javascript....so be patient...lol !

Thank you !  I will keep you informed.

Login or Signup to post a comment