1

I have excel file in shared document in sharepoint 2013. I want to store the content of that file in array variable and send it to server side for processing.

I am getting the client context loaded,but i want to get the records present inside in the file. I have excel file present inside SharedDocument/test folder

ExecuteOrDelayUntilScriptLoaded(viewfiles, "sp.js");
function viewfiles(){ 
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle('Documents');
var query = SP.CamlQuery.createAllItemsQuery();
query.set_folderServerRelativeUrl('http://win-mjphj36pn7d:55555/sites/Demo/Shared%20Documents/test');
allItems = list.getItems(query);
context.load(allItems, 'Include(Title, ContentType, File)');
context.executeQueryAsync(
Function.createDelegate(this, function (sender, args) {
                     var fileUrls = ""; var fileUrls = "";
                      var ListEnumerator = this.allItems.getEnumerator();
                       while(ListEnumerator.moveNext())
                       {
                        var currentItem = ListEnumerator.get_current();
                        var _contentType = currentItem.get_contentType();
                         if(_contentType.get_name() != "Folder")
                           {
                            var File = currentItem.get_file();
                            if(File != null)
                              {
                               fileUrls += File.get_serverRelativeUrl() + '\n';
                              }
                           }
                       }
                      alert(fileUrls);
                }),

Function.createDelegate(this, function (sender, args) {
          alert("failed. Message:" + args.get_message());                    
             })
            );

Please suggest how i get all data in the file in a array var or string

Surendra Mourya
  • 593
  • 3
  • 8
  • 29

1 Answers1

0

Apparently for some reason the openbinary method from CSOM is not available in JSOM (or a least not documented).
So I'd suggest that you first try within the console in the browser's context to see if it's here. Otherwrise see the REST API documentation (second example) to retrieve the binary value.
Here is the jsom documentation and the CSOM documentation of this same aspect.

baywet
  • 4,377
  • 4
  • 20
  • 49