Forge Component
(64)
Published on 2019-08-27 by Hanno
64 votes
Published on 2019-08-27 by Hanno

Hi guys,

I need to edit an Excel workbook which is in Box service,

and I tried in following way.


When I reached the Workbook_Open action, following error occured.


Could you please help me to fix this problem?


Hi Kazuya

Can you perhaps show us the parameters you are passing in to the workbook_open action? 

Hanno 

Hi Hanno,

thank you very much for your reply,

and I'll show you the paremeters below.

The parameters for TextToBinaryData action is as below.


The Excel file in the Box can be downloaded

when I access via browser, 

using ExternalURL at the end of ScreenAction.


Kazuya

Hi Kazuya

Is TextToBinaryData the correct option? Have you perhaps tested a file download to see that the file returned by HTTPGET and TextToBinaryData actions is a valid Excel file?


Regards
Hanno

Hi Hanno,


>Have you perhaps tested a file download to see that the file returned by HTTPGET and TextToBinaryData actions is a valid Excel file?

Yes I tried it,  but downloaded Excel file was broken and cannot be opened.

Is there any idea to get binary data from HTTPResponse

or other way to get Excel from Box service?


Regards

Kazuya


Solution

TextToBinaryData will most certainly corrupt any data that was originally binary, but represented as Text (or, rather, the Text will already contain a corrupted representation of the original binary data).

Where is HTTPGet from? I would use GetRequest_Submit from the HTTPRequestHandler, it has BinaryContent as output you can use directly.

Solution

My guess would be that the HTTPGET would return Base64 encoded text that needs to be converted to binary data.

The BinaryData extension has a method Base64ToBinary that you could use. Perhaps try that?

Kilian Hekhuis wrote:

TextToBinaryData will most certainly corrupt any data that was originally binary, but represented as Text (or, rather, the Text will already contain a corrupted representation of the original binary data).

Where is HTTPGet from? I would use GetRequest_Submit from the HTTPRequestHandler, it has BinaryContent as output you can use directly.

Hi Kilian,

thank you for your reply.


I tried to use GetRequest_Submit as you mentioned,

and now, it is working correctly.

I can open the Excel file from Box.


Thank you so much again!


Hanno wrote:

My guess would be that the HTTPGET would return Base64 encoded text that needs to be converted to binary data.

The BinaryData extension has a method Base64ToBinary that you could use. Perhaps try that?


Hi Hanno,

I resolve the problem by Kilian's suggestion as above.


Thank you for your help!


Hi Kazuya,

Great to hear it's solved. Happy coding!