使用 C#,想在 google doc 上上传 excel 文件。下面的语法用于上传 xls 文件
//use Content-Type: text/csv
entry.MediaSource = new MediaFileSource("E:\\Emailcontent.xls", "text/csv");
但它不工作,上传文件转换为 csv 后。但我不想要这种转换。我只想在我的谷歌文档中上传我的 excel 文件。帮助我上传没有转换的 excel 文件。提前谢谢
string USERNAME = "xxx@gmail.com";
string PASSWORD = "xxxxx";
// Start the service and set credentials
DocumentsService service = new DocumentsService("MyDocumentsListIntegration-v1");
service.setUserCredentials(USERNAME, PASSWORD);
Authenticator authenticator = new ClientLoginAuthenticator("TestApi", Google.GData.Client.ServiceNames.Documents, service.Credentials);
DocumentEntry entry = new DocumentEntry();
// Set the document title
entry.Title.Text = "Legal Contract";
entry.IsSpreadsheet = true;
// Set the media source
//entry.MediaSource = new MediaFileSource("E:\\New Microsoft Office Word Document.doc", "application/msword");
entry.MediaSource = new MediaFileSource("E:\\Emailcontent.xls", "text/csv");
// Define the resumable upload link
Uri createUploadUrl = new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full");
AtomLink link = new AtomLink(createUploadUrl.AbsoluteUri);
link.Rel = ResumableUploader.CreateMediaRelation;
entry.Links.Add(link);
// Set the service to be used to parse the returned entry
entry.Service = service;
// Instantiate the ResumableUploader component.
ResumableUploader uploader = new ResumableUploader();
// Set the handlers for the completion and progress events
uploader.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(OnDone);
uploader.AsyncOperationProgress += new AsyncOperationProgressEventHandler(OnProgress);
// Start the upload process
uploader.InsertAsync(authenticator, entry, new object());