I am trying to create a new spreadsheet in Google Drive using Google Script. When using the code below the Mimetypes work in some instances (like OPENDOCUMENT_SPREADSHEET and JAVASCRIPT) but not in others (like GOOGLE_DRAWINGS and GOOGLE_SHEETS). Can someone explain the reason for this?
function createSheet() {
var mimeTest = MimeType.OPENDOCUMENT_SPREADSHEET;
var quickReferenceSheet = DriveApp.createFile("test", "", mimeTest);
}
Error message comes up as "Invalid argument: file.contentType (line 3, file "Sheet Formula Check")"
Thank you in advance for your time.
If my understanding is correct, how about this sample script? Unfortunately, Google Docs cannot be created using DriveApp.createFile()
. I think that this might be the specification. So how about using the create method of Class SpreadsheetApp?
var spreadsheet = SpreadsheetApp.create("test");
If you want to create new Spreadsheet using Drive API, how about this sample script? When you use this script, please enable Drive API at Advanced Google Services.
var spreadsheet = Drive.Files.insert({mimeType: MimeType.GOOGLE_SHEETS, title: "test", parents: [{id: "### folderId ###"}]});
If I misunderstood your question, I apologize.