2009-10-14 17 views
6

में Google डॉक्स का उपयोग करें मैं अपने प्रोजेक्ट में GOOGLE DOCS का उपयोग कैसे कर सकता हूं जो मैं सी # के साथ कोड के रूप में एएसपीनेट का उपयोग कर कर रहा हूं।एएसपीनेट एप्लिकेशन

असल में मुझे ब्राउज़र में केवल पढ़ने के रूप में कुछ पीडीएफ, डॉक्टर, डॉक्स, एक्सेल दस्तावेज प्रदर्शित करने की आवश्यकता है।

अग्रिम धन्यवाद

उत्तर

3

Google डॉक्स के लिए एक एपीआई है।

Google दस्तावेज़ सूची डेटा API क्लाइंट अनुप्रयोगों को पर प्रोग्रामेटिक रूप से पहुंचने और Google दस्तावेज़ों के साथ संग्रहीत उपयोगकर्ता डेटा में हेरफेर करने की अनुमति देता है।

इसे documentation देखें, इसमें उदाहरण हैं और आपको Google डॉक्स के आधार पर कुछ विकसित करने की आवश्यकता होगी।

1
using System; 
using System.IO; 
using System.Net; 
using Google.Documents; 
using Google.GData.Client; 

namespace Google 
{ 
    class Program 
    { 
     private static string applicationName = "Testing"; 

     static void Main(string[] args) 
     { 
      GDataCredentials credentials = new GDataCredentials("[email protected]", "password"); 
      RequestSettings settings = new RequestSettings(applicationName, credentials); 
      settings.AutoPaging = true; 
      settings.PageSize = 100; 
      DocumentsRequest documentsRequest = new DocumentsRequest(settings); 
      Feed<document> documentFeed = documentsRequest.GetDocuments(); 
      foreach (Document document in documentFeed.Entries) 
      { 
       Document.DownloadType type = Document.DownloadType.pdf; 

       Stream downloadStream = documentsRequest.Download(document, type); 

       Stream fileSaveStream = new FileStream(string.Format(@"C:\Temp\{0}.pdf", document.Title), FileMode.CreateNew); 

       if (fileSaveStream != null) 
       { 
        int nBytes = 2048; 
        int count = 0; 
        Byte[] arr = new Byte[nBytes]; 

        do 
        { 
         count = downloadStream.Read(arr, 0, nBytes); 
         fileSaveStream.Write(arr, 0, count); 

        } while (count > 0); 
        fileSaveStream.Flush(); 
        fileSaveStream.Close(); 
       } 
       downloadStream.Close(); 
      } 

     } 
    } 
}