2013-01-10 2 views
1

Google 애플리케이션의 일부 사용자 정보를 기반으로 문서를 생성하려고합니다.google apps 만든 문서의 경로를 지정하십시오.

var titleAndPath = "./some/other/path/bar.doc" 
var info = "foo"; 
var currentDoc = DocumentApp.create(titleAndPath); 
var title = currentDoc.appendParagraph(info); 

그러나, 나는 실제로 '루트'Google 드라이브 디렉토리를 제외하고 아무것도에 저장할 수없는 것 :

나는 (간체) 다음과 같은 코드가 있습니다. 다른 말로하면, 하위 폴더에 문서를 저장하고 싶습니다. Google API에이 기능이 있습니까? 문서 API를 사용할 수 없음 (https://developers.google.com/apps-script/class_document#saveAndClose)을 확인했습니다.

희망적으로이 사람은 내가 두려워하는만큼 분명히 명백하지 않습니다.

미리 감사드립니다.

답변

2

DocumentApp.create를 호출 할 때 path라는 개념이 없습니다. 즉, 슬래시와 점은 파일 이름의 다른 문자로 해석됩니다. 당신이해야 할 일은 DriveApp 클래스를 DocumentApp 클래스와 함께 사용하는 것입니다. 다음과 같이 표시됩니다 (테스트 안 함).

var title = "bar.doc"; 
var doc = DocumentApp.create (title); 
var docId = doc.getId();      // retrieve the document unique id 
var docFile = DriveApp.getFileById (docId); // then get the corresponding file 
// Use the DriveApp folder creation and navigation mechanisms either: 
// - to get to your existing folder, or 
// - to create the folder path you need. 
var folder = … 
folder.addFile (docFile); 
관련 문제