I am writing desktop program to interact with Google spreadsheets
and for that I need to upload excel sheet
and convert it Google spreadsheet
by programmatically. I checked Google drive and Google spread sheet API's could not find way to do this. If someone can any one suggest way to do this it would be grate help.
This is code I have now, which is uploading excel file correctly but it does not converted to Google spread sheet.
Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();
body.Title = "My document";
body.Description = "A test document";
body.MimeType = "application/vnd.ms-excel";
byte[] byteArray = System.IO.File.ReadAllBytes("test.xlsx");
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, "application/vnd.google-apps.spreadsheet");
request.Convert = true;
request.Upload();
Google.Apis.Drive.v2.Data.File file = request.ResponseBody;
Console.WriteLine("File id: " + file.Id);
Console.WriteLine("Press Enter to end this process.");
Console.ReadLine();
I used the Drive API, below is a snippet of code I used to convert an XLS File
function convert(xlsxFileId, name) {
var xlsxBlob = xlsxFileId;
var file = {
title: name,
//Which Drive Folder do you want the file to be placed in
parents: [{'id':'FOLDER_ID'}],
key: 'XXXX',
value: 'XXXX',
visibility: 'PRIVATE'
};
file = Drive.Files.insert(file, xlsxBlob, {
convert: true
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.