【发布时间】:2019-10-21 13:19:09
【问题描述】:
我正在寻找如何将 SharePoint 文档库文件输出到 csv 文件。我找到了几乎可以让我到达那里的脚本,但我不知道如何更新代码以将信息导出到 csv 文件,而不是导出到 console.log() 或 alert()。我尝试的一切都会破坏代码。我回顾了其他显示如何添加到 CSV 的 JavaScript 概念,但我再次脚本概念破坏了我正在尝试修改的代码。我正在使用的脚本。此外,脚本输出文件名。我想获得有关如何不仅输出文件名的帮助,而且我喜欢输出、修改日期、创建日期和文件链接。我希望这是可能的,我感谢任何帮助实现这个概念。我使用的脚本如下。
jQuery(document).ready(function() {
var scriptbase = _spPageContextInfo.webServerRelativeUrl + "/_layouts/15/";
$.getScript(scriptbase + "SP.Runtime.js", function() {
$.getScript(scriptbase + "SP.js", function() {
$.getScript(scriptbase + "SP.DocumentManagement.js", createDocumentSet);
});
});
});
var docSetFiles;
function createDocumentSet() {
//Get the client context,web and library object.
clientContext = new SP.ClientContext.get_current();
oWeb = clientContext.get_web();
var oList = oWeb.get_lists().getByTitle("Fact Sheets & Agreements");
clientContext.load(oList);
//Get the root folder of the library
oLibraryFolder = oList.get_rootFolder();
var documentSetFolder = "sites/nbib/ep/Fact%20Sheets/";
//Get the document set files using CAML query
var camlQuery = SP.CamlQuery.createAllItemsQuery();
camlQuery.set_folderServerRelativeUrl(documentSetFolder);
docSetFiles = oList.getItems(camlQuery);
//Load the client context and execute the batch
clientContext.load(docSetFiles, 'Include(File)');
clientContext.executeQueryAsync(QuerySuccess, QueryFailure);
}
function QuerySuccess() {
//Loop through the document set files and get the display name
var docSetFilesEnumerator = docSetFiles.getEnumerator();
while (docSetFilesEnumerator.moveNext()) {
var oDoc = docSetFilesEnumerator.get_current().get_file();
alert("Document Name : " + oDoc.get_name());
console.log("Document Name : " + oDoc.get_name());
}
}
function QueryFailure() {
console.log('Request failed - ' + args.get_message());
}
【问题讨论】:
标签: javascript jquery sharepoint