# How could I upload a XLS file to Cloud and then plot it?

Bug introduced in 10.0 and fixed in 10.3 or earlier

I want to upload a file to the Wolfram Cloud and plot the list: So I use the following code to check its head at the beginning:

CloudDeploy[FormFunction[{"file" -> "XLS"},Head[#file]&], Permissions -> "Public"]


Output is:

But when I upload a XLS file and then submit,it can not continue,it throws a error:

upload a file of type XLS

If I check this file type on my computer:

FileFormat["F:\\learning_mma\\testfile.xls"]


result is:

XLS

So my question is how to upload a XLS file to the Clould and then plot it?

• This is a related question and still unanswered by WRI. I did ask at the WTC conference last week, sent a mail to a main developer, but never heard back (maybe it went into a Spam folder? Or they are very very busy fixing things. Probably.) – Rolf Mertig Oct 31 '14 at 14:42
• yes,simular this code:CloudDeploy[ FormFunction[{"image" -> "Image"}, EdgeDetect[#image] &, "JPEG"]] can run.and CloudDeploy[FormFunction[{"lis"->"List"},Length[#lis]&],Permissions->"Public"] also can run.But XLS can't be done. – partida Oct 31 '14 at 15:09
• @Rolf Mertig I feedback to wolfram and get the answer.This is a known issue with using "UploadedFile" with FormFunction. I have updated the bug report with your case. Thank you very much for giving us feedback. Sincerely, Xin Xiao Wolfram Technical Support – partida Nov 11 '14 at 4:59
• If anyone knows whether this bug has been fixed, please update the bug header (see meta.mathematica.stackexchange.com/questions/1610/…). – Michael E2 Aug 9 '15 at 12:03
• @MichaelE2 It works now. Difficult to say which (cloud) version corrected the bug. Not really relevant though, since only the latest version (10.3 at the moment) is accessible. – Sjoerd C. de Vries Dec 6 '15 at 22:41

Suppose you create

Export["test.xls", RandomReal[1, 42]]


Then this seems to work in creating a nice plot (it will not look nice without specifying FontFamily, somehow, strangely).

CloudDeploy[
FormFunction[{"file" -> "XLS"},
ListLinePlot[Transpose[First[#file]],
LabelStyle -> {FontFamily -> "Tahoma", FontSize -> 16}] &],
Permissions -> "Public"]


So, let's hope this will be fixed in the next version. Until then this simple workaround, using "Binary" as an intermediate format, will do it:

  CloudDeploy@
FormFunction[{"data" -> "Binary"},
(
CloudPut[#data, "excelFile"];
) &
]


Then, after uploading an Excel file through the browser, you can get the content of the Excel file into Mathematica simply by:

Composition[ ImportString[#, "XLSX"] &,
ExportString[#, "Binary"] &,
CloudGet
] @ "excelFile"


If you're willing to use a text file instead of XLS, here's the code I use to upload & plot two columns from a text file:

CloudDeploy[FormFunction[
"x" -> "Text",
ListPlot[ImportString[#x, "Data"]] &, "PNG"
], Permissions -> "Public"]