Page 1 of 1

NG Client - showFileOpenDialog inconsistent filename

PostPosted: Thu Dec 13, 2018 9:56 pm
by Louis.Winter
I am trying to use plugins.file.showFileOpenDialog to allow the user to upload an Excel (.xlsx) file. The problem I am having is that some files return a full path in the JSFile object passed to my callback method, and others have just a filename.

Examples:
Uploading Good.xlsx results in a JSFile object of:
JSFile[name:C:\Users\XXXXX\AppData\Local\Temp\upload_44f920dc_525e_423b_92cc_8463bb48868e_420537147.tmp,contenttype:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet]

Uploading Bad.xlsx results n a JSFile object of:
JSFile[name:Bad.xlsx,contenttype:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet]

Both of the files open correctly in Excel.

Also, I have a download option to create an Excel file which works correctly. The file created by scopes.svyExcelUtils.createWorkbook won't upload because the JSFile object is just a name and not the full path to the temp file.

The following shows what I'm currently doing.
Code: Select all
function onAction$Upload(event) {
   plugins.file.showFileOpenDialog(1,null,false,new Array("Excel Files", "xlsx"),onUpload,'Select Spreadsheet to Upload');
}

function onUpload(files) {
   application.output(files[0]);
   var wb = scopes.svyExcelUtils.getWorkbook(files[0]);
   /* The getWorkbook call works for the first file and not for the second. */
}


Thoughts?

Louis Winter