コード例 #1
0
        //Fetch all worksheets for given Spreadsheet

        public static ArrayList getWorksheetList(string userName, string passWord, string spreadSheetName)
        {
            ArrayList worksheetList = new ArrayList();

            SpreadsheetsService service = new SpreadsheetsService(spreadSheetName + "Service");

            //You could set it up from DB or config file also. This is not a reccomended way. Just an easy way to show fetching
            service.setUserCredentials(userName, passWord);

            SpreadsheetQuery query = new SpreadsheetQuery();

            SpreadsheetFeed feed = service.Query(query);

            foreach (SpreadsheetEntry entry in feed.Entries)
            {
                if (entry.Title.Text == spreadSheetName)
                {
                    AtomLink link = entry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);

                    WorksheetQuery wquery = new WorksheetQuery(link.HRef.ToString());
                    WorksheetFeed  wfeed  = service.Query(wquery);

                    foreach (WorksheetEntry worksheet in wfeed.Entries)
                    {
                        worksheetList.Add(worksheet.Title.Text);
                    }
                }
            }

            return(worksheetList);
        }
コード例 #2
0
ファイル: ManagerWindow.cs プロジェクト: bpasha7/FinalWork
        private string ToGoogleTable()
        {
            WorksheetFeed  wsFeed    = TargetTable.Worksheets;
            WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];
            // Define the URL to request the list feed of the worksheet.
            AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            // Fetch the list feed of the worksheet.
            ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
            ListFeed  listFeed  = service.Query(listQuery);

            CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
            CellFeed  cellFeed  = service.Query(cellQuery);

            CellEntry cellEntry = new CellEntry(1, 1, "oid");

            cellFeed.Insert(cellEntry);
            cellEntry = new CellEntry(1, 2, "value");
            cellFeed.Insert(cellEntry);
            cellEntry = new CellEntry(1, 3, "type");
            cellFeed.Insert(cellEntry);
            ProgressBarSetStartParams(progressBar1, ListData[ListData.Count - 1].Count);
            tabControlShow(progressBar1);
            tabControlShow(label3);
            for (int i = 0; i < ListData[ListData.Count - 1].Count; i++)
            {
                IncrementProgressbar(progressBar1);
                IncrementGeneralLabel(string.Format("Выполнено {0}/{1}", i + 1, ListData[ListData.Count - 1].Count));
                service.Insert(listFeed, ListData[ListData.Count - 1].GetCustom(i));
            }
            tabControlShow(progressBar1, false);
            tabControlShow(label3, false);
            return("Данные записаны");
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Environment.CurrentDirectory = Environment.CurrentDirectory.Substring(0, Environment.CurrentDirectory.LastIndexOf("osum", StringComparison.Ordinal)) + @"\osum\osum\Localisation\";
            ss.setUserCredentials("*****@*****.**", "osumisawsum");

            SpreadsheetFeed feed = ss.Query(new SpreadsheetQuery());

            SpreadsheetEntry sheet = null;

            //get spreadsheet
            foreach (var entry in feed.Entries.OfType <SpreadsheetEntry>())
            {
                if (entry.Title.Text == "osu!stream localisation")
                {
                    sheet = entry;
                    break;
                }
            }

            if (sheet == null)
            {
                Console.WriteLine("failed to get spreadsheet");
                Console.ReadLine();
            }

            //get worksheet
            AtomLink       link  = sheet.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);
            WorksheetQuery query = new WorksheetQuery(link.HRef.ToString());
            WorksheetFeed  wfeed = ss.Query(query);


            WorksheetEntry worksheet = wfeed.Entries[0] as WorksheetEntry;

            ProcessWorksheet(worksheet);
        }
コード例 #4
0
        /// <summary>
        /// Handler for when the Spreadsheets tab becomes the active tab
        /// </summary>
        /// <param name="sender">Ignored</param>
        /// <param name="e">Ignored</param>
        void OnEnterSelectSpreadsheetTab(object sender, System.EventArgs e)
        {
            service.setUserCredentials(this.usernameTextBox.Text, this.passwordTextBox.Text);

            SpreadsheetQuery query = new SpreadsheetQuery();

            setSpreadsheetListView(service.Query(query));
        }
コード例 #5
0
        public IEnumerable <SpreadsheetEntry> GetSpreadsheetList()
        {
            // Instantiate a SpreadsheetQuery object to retrieve spreadsheets.
            SpreadsheetQuery query = new SpreadsheetQuery();

            // Make a request to the API and get all spreadsheets.
            SpreadsheetFeed feed = _service.Query(query);

            return(feed.Entries.Cast <SpreadsheetEntry>());
        }
コード例 #6
0
        public void LoadSpreadSheet(string spreadSheetId)
        {
            SpreadsheetQuery query = new SpreadsheetQuery();

            query.Uri = new Uri("https://spreadsheets.google.com/feeds/spreadsheets/private/full/" + spreadSheetId);

            SpreadsheetFeed feed = service.Query(query);

            spreadSheetEntry = (SpreadsheetEntry)feed.Entries[0];
        }
コード例 #7
0
        protected void button2_Click(object sender, EventArgs e)
        {
            if (spreadsheetName.Length > 0)
            {
                if (listView2.SelectedIndex > -1)
                {
                    wrkSheetName = listView2.SelectedItem.Text;
                }
                else
                {
                    return;
                }

                SpreadsheetsService GoogleExcelService;
                GoogleExcelService = new SpreadsheetsService("Spreadsheet-Abhishek-App");
                GoogleExcelService.setUserCredentials("*****@*****.**", "Lucknow@");
                // ListQuery query = new ListQuery("0AmYgMIof-5mgdGM2OGxoTmUyc3JRTFlMZ1BTUG5SOVE", "1", "public", "values");
                // ListQuery query = new ListQuery("https://docs.google.com/a/laitkor.com/spreadsheet/ccc?key=0AttN4WWVg0qodF9RSG8tOXptV0RwZm1LOWFJQ3g0Mnc#gid=0", "1", "public", "values");
                //ListFeed myFeed = GoogleExcelService.Query(query);
                SpreadsheetQuery query  = new SpreadsheetQuery();
                SpreadsheetFeed  myFeed = GoogleExcelService.Query(query);
                foreach (SpreadsheetEntry mySpread in myFeed.Entries)
                {
                    if (mySpread.Title.Text == spreadsheetName)
                    {
                        WorksheetFeed wfeed = mySpread.Worksheets;
                        foreach (WorksheetEntry wsheet in wfeed.Entries)
                        {
                            if (wsheet.Title.Text == wrkSheetName)
                            {
                                AtomLink  atm    = wsheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);
                                ListQuery Lquery = new ListQuery(atm.HRef.ToString());
                                ListFeed  LFeed  = GoogleExcelService.Query(Lquery);
                                myTable = new DataTable();
                                DataColumn DC;
                                foreach (ListEntry LmySpread in LFeed.Entries)
                                {
                                    DataRow myDR = myTable.NewRow();
                                    foreach (ListEntry.Custom listrow in LmySpread.Elements)
                                    {
                                        DC       = myTable.Columns[listrow.LocalName] ?? myTable.Columns.Add(listrow.LocalName);
                                        myDR[DC] = listrow.Value;
                                    }
                                    myTable.Rows.Add(myDR);
                                }
                                dataGridView1.DataSource = myTable;
                                dataGridView1.DataBind();
                            }
                        }
                    }
                }
            }
            //System.Windows.Forms.MessageBox.Show("Data Reading is Completed");
            ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Data Reading is Completed');", true);
        }
コード例 #8
0
        public ListFeed GetAllRows()
        {
            if (_listFeedLink == null || _service == null)
            {
                return(null);
            }

            // Fetch the list feed of the worksheet.
            var listQuery = new ListQuery(_listFeedLink.HRef.ToString());

            return(_service.Query(listQuery));
        }
コード例 #9
0
        public void AddNewHeader(string header)
        {
            WorksheetEntry.Cols += 1;
            WorksheetEntry.Update();
            CellQuery cellQuery = new CellQuery(WorksheetEntry.CellFeedLink);

            cellQuery.MaximumRow = 1;
            //cellQuery.Range = "A543:L543";
            CellFeed  cellFeed  = service.Query(cellQuery);
            CellEntry cellEntry = new CellEntry(1, (uint)cellFeed.Entries.Count + 1, header);

            cellFeed.Insert(cellEntry);
        }
コード例 #10
0
        private void FindValidAuctionTypes()
        {
            validTypes = new List <string>();

            WorksheetQuery      wsQuery          = new WorksheetQuery(String.Format(@"http://spreadsheets.google.com/feeds/worksheets/{0}/private/full", NotificationAdministrationSheetKey));
            AtomEntryCollection worksheetEntries = MySpreadsheetService.Query(wsQuery).Entries;

            foreach (WorksheetEntry sheet in worksheetEntries)
            {
                if (!"Admin,Template".Contains(sheet.Title.Text))
                {
                    validTypes.Add(sheet.Title.Text);
                }
            }
        }
コード例 #11
0
        private void GetLocalizationList()
        {
            if (string.IsNullOrEmpty(settings.spreadSheetKey))
            {
                Debug.LogError("spreadSheetKey can not be null!");
                return;
            }

            PlayerPrefs.SetString(PREF_SHEET_KEY, settings.spreadSheetKey);
            PlayerPrefs.Save();

            if (IsTokkenEmpty)
            {
                EditorUtility.ClearProgressBar();
                GetAccessCode();
                return;
            }

            progressMessage = "Authenticating...";
            GOAuth2RequestFactory requestFactory = RefreshAuthenticate();
            SpreadsheetsService   service        = new SpreadsheetsService(appName);

            service.RequestFactory = requestFactory;

            SpreadsheetQuery query = new SpreadsheetQuery();

            query.Uri       = new System.Uri(urlRoot + settings.spreadSheetKey);
            progressMessage = "Get list of spreadsheets...";

            spreadsheetFeed = service.Query(query);
            if ((spreadsheetFeed == null) || (spreadsheetFeed.Entries.Count <= 0))
            {
                Debug.LogError("Not found any data!");
                EditorUtility.ClearProgressBar();
                return;
            }

            AtomEntry      mySpreadSheet = spreadsheetFeed.Entries[0];
            AtomLink       link          = mySpreadSheet.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);
            WorksheetQuery sheetsQuery   = new WorksheetQuery(link.HRef.ToString());
            WorksheetFeed  sheetsFeed    = service.Query(sheetsQuery);

            foreach (WorksheetEntry sheet in sheetsFeed.Entries)
            {
                wantedSheetNames.Add(sheet.Title.Text);
            }
            localizationCount = wantedSheetNames.Count;
        }
コード例 #12
0
 private void UpdateGoogleTables_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (service != null)
     {
         GoogleTableListView.Items.Clear();
         ImageList IL = new ImageList();
         IL.ImageSize = new Size(32, 32);
         IL.Images.Add(Properties.Resources.Gtable as Bitmap);
         GoogleTableListView.LargeImageList = IL;
         SpreadsheetQuery query2 = new SpreadsheetQuery();
         SpreadsheetFeed  feed2  = service.Query(query2);
         MySpreadsheet = new List <SpreadsheetEntry>();
         foreach (SpreadsheetEntry entry in feed2.Entries)
         {
             MySpreadsheet.Add(entry);
             GoogleTableListView.Items.Add(entry.Title.Text, 0);
         }
         TakeTable.Enabled = true;
         ToLog("Обновление таблиц", string.Format("Список таблиц Google обновлен"));
     }
     else
     {
         MessageBox.Show("Вы не подключились к Google Disk!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
 }
コード例 #13
0
        // GET: /Configuration/
        //[Authorize(Roles = "Admin, SuperUser")]
        public ActionResult Index(GoogleAPIAccess model)
        {
            ViewBag.Message = "Add / Update / Remove Google documents";
            if (model.AccessCode != null)  //after authorization
            {
                ////////////////////////////////////////////////////////////////////////////
                // STEP 5: Make an OAuth authorized request to Google
                ////////////////////////////////////////////////////////////////////////////

                // Initialize the variables needed to make the request
                GOAuth2RequestFactory requestFactory =
                    new GOAuth2RequestFactory(null, "TaskTimer", model);
                SpreadsheetsService service = new SpreadsheetsService("TaskTimer");
                service.RequestFactory = requestFactory;


                // Instantiate a SpreadsheetQuery object to retrieve spreadsheets.
                SpreadsheetQuery query = new SpreadsheetQuery();

                // Make a request to the API and get all spreadsheets.
                SpreadsheetFeed feed = service.Query(query);

                //GoogleDocuments = new GoogleDocumentModel();
                //GoogleDocuments.GoogleAPIAccess = model;
                GoogleDocuments.Documents = feed.Entries;
            }
            return(View(GoogleDocuments));
        }
コード例 #14
0
    public OAuthTest()
    {
        Debug.WriteLine("Calling: AuthGoogleDataInterface()");
        bool init = AuthGoogleDataInterface();

        if (init)
        {
            GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "My App User Agent", this.param);
            //requestFactory.CustomHeaders.Add(string.Format("Authorization: Bearer {0}", credential.Token.AccessToken));
            var service = new SpreadsheetsService("MyService");
            service.RequestFactory = requestFactory;
            SpreadsheetQuery query = new SpreadsheetQuery();

            // Make a request to the API and get all spreadsheets.
            SpreadsheetFeed feed = service.Query(query);

            // Iterate through all of the spreadsheets returned
            foreach (SpreadsheetEntry entry in feed.Entries)
            {
                // Print the title of this spreadsheet to the screen
                Debug.WriteLine(entry.Title.Text);
            }
        }
        Debug.WriteLine(m_Init);
    }
コード例 #15
0
        public AtomEntryCollection ObtenerListaHojas(string linkLibro, SpreadsheetsService servicio)
        {
            var consulta = new WorksheetQuery(linkLibro);
            var hojas    = servicio.Query(consulta);

            return(hojas.Entries);
        }
コード例 #16
0
ファイル: MainWindow.cs プロジェクト: mach-kernel/GAppADD
        // Start Google Library Calls

        public void processLogin(string username, string password)
        {
            try
            {
                SpreadsheetsService getAcct = new SpreadsheetsService("GAppADDAutoUser");
                getAcct.setUserCredentials(username, password);

                SpreadsheetQuery query = new SpreadsheetQuery();
                SpreadsheetFeed  feed  = getAcct.Query(query);
                foreach (SpreadsheetEntry entry in feed.Entries)
                {
                    sheetView.Items.Add(entry.Title.Text.ToString());
                }
            }
            catch (Exception e)
            {
                string loginExc = e.ToString();
                if (loginExc.Contains("InvalidCredentials"))
                {
                    MessageBox.Show("You fatfingered the credentials. Try logging in again with the right ones.", "Error (how could you do this to me?)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("The following error has occured: " + e.ToString(), "Error argh bah no:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }
                loginFailed = true;
                loginWorker.CancelAsync();
            }
        }
コード例 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                OAuth2Parameters      parameters_lst = oauthcredentials();
                GOAuth2RequestFactory requestFactory =
                    new GOAuth2RequestFactory(null, "Fusion-SpreadSheet", parameters_lst);
                SpreadsheetsService service = new SpreadsheetsService("Fusion-SpreadSheet");
                service.RequestFactory = requestFactory;

                SpreadsheetQuery query = new SpreadsheetQuery();


                // Make a request to the API and get all spreadsheets.
                SpreadsheetFeed feed = service.Query(query);

                // Iterate through all of the spreadsheets returned
                ddlexcellst.Items.Add("------------------- Select------------------");
                foreach (SpreadsheetEntry entry in feed.Entries)
                {
                    // Print the title of this spreadsheet to the screen

                    //Response.Write(entry.Title.Text);
                    ddlexcellst.Items.Add(entry.Title.Text);
                }
            }
        }
        catch (Exception)
        {
            Response.Redirect("Default.aspx");
        }
    }
コード例 #18
0
        public DictionaryTable Download(string sheetName)
        {
            var            service   = new SpreadsheetsService(applicationName);
            WorksheetEntry worksheet = GetWorksheetEntres(service).FirstOrDefault(e => e.Title.Text == sheetName) as WorksheetEntry;

            if (worksheet == null)
            {
                return(null);
            }
            List <DictionaryItem> retval = new List <DictionaryItem>();

            // Fetch the cell feed of the worksheet.
            CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);

            cellQuery.MaximumColumn = 2;

            CellFeed cellFeed = service.Query(cellQuery);

            for (int i = 0; i < cellFeed.Entries.Count; i = i + 2)
            {
                retval.Add(
                    new DictionaryItem(new string[]
                                       { ((CellEntry)cellFeed.Entries[i]).Value, ((CellEntry)cellFeed.Entries[i + 1]).Value }));
            }
            return(new DictionaryTable(sheetName, retval.ToArray()));
        }
コード例 #19
0
        private List <CellFeed> DoCellQuery(SpreadsheetsService service, WorksheetFeed wsFeed, uint minRow, uint minColumn, uint maxColumn)
        {
            List <CellFeed> cellFeeds = new List <CellFeed>();
            int             i         = 0;

            foreach (WorksheetEntry worksheet in wsFeed.Entries)
            {
                if (worksheet.Title.Text[0] != '0')
                {
                    CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
                    cellQuery.MinimumRow    = minRow;
                    cellQuery.MinimumColumn = minColumn;
                    cellQuery.MaximumColumn = maxColumn;
                    CellFeed cellFeed = service.Query(cellQuery);

                    cellFeeds.Insert(i, cellFeed);
                    i++;
                }
                else
                {
                    CellFeed cellFeed = null;
                    cellFeeds.Insert(i, cellFeed);
                    i++;
                }
            }

            return(cellFeeds);
        }
コード例 #20
0
        private void GetSpreadsheet(SpreadsheetsService service)
        {
            SpreadsheetQuery query       = new SpreadsheetQuery();
            SpreadsheetFeed  feed        = service.Query(query);
            SpreadsheetEntry spreadsheet = null;

            foreach (SpreadsheetEntry entry in feed.Entries)
            {
                if (!entry.Title.Text.Equals("Boardgame Stats"))
                {
                    continue;
                }

                spreadsheet = entry;
            }

            if (spreadsheet == null)
            {
                MessageBox.Show("You don't appear to have access to the proper spreadsheet.");
                return;
            }

            WorksheetFeed wsFeed = spreadsheet.Worksheets;

            Games = wsFeed;

            GetGameDateName(service, spreadsheet, wsFeed);
        }
コード例 #21
0
        public DictionaryTable Download(string sheetName)
        {
            SpreadsheetsService service = new SpreadsheetsService(applicationName);

            service.setUserCredentials(userName, password);
            WorksheetEntry worksheet = this.GetWorksheetEntrees(service).FirstOrDefault(e => e.Title.Text == sheetName);

            if (worksheet == null)
            {
                return(null);
            }

            CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);

            cellQuery.MaximumColumn = 2;

            CellFeed cellFeed            = service.Query(cellQuery);
            List <DictionaryItem> retval = new List <DictionaryItem>();

            for (int i = 0; i < cellFeed.Entries.Count; i = i + 2)
            {
                retval.Add(
                    new DictionaryItem(new string[] { ((CellEntry)cellFeed.Entries[i]).Value, ((CellEntry)cellFeed.Entries[i + 1]).Value }));
            }
            return(new DictionaryTable(sheetName, retval.ToArray()));
        }
コード例 #22
0
        /// <summary>
        /// Inserts a new row in the specified worksheet.
        /// </summary>
        /// <param name="service">an authenticated SpreadsheetsService object</param>
        /// <param name="entry">the worksheet into which the row will be inserted</param>
        /// <returns>the inserted ListEntry object, representing the new row</returns>
        private static ListEntry InsertRow(SpreadsheetsService service, WorksheetEntry entry)
        {
            AtomLink listFeedLink = entry.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            ListQuery query = new ListQuery(listFeedLink.HRef.ToString());
            ListFeed  feed  = service.Query(query);

            ListEntry firstRow = feed.Entries[0] as ListEntry;
            ListEntry newRow   = new ListEntry();

            Console.WriteLine();
            Console.WriteLine("Inserting a new row...");
            foreach (ListEntry.Custom element in firstRow.Elements)
            {
                Console.Write("Enter the value of column \"{0}\": ", element.LocalName);
                String elementValue = Console.ReadLine();

                ListEntry.Custom curElement = new ListEntry.Custom();
                curElement.LocalName = element.LocalName;
                curElement.Value     = elementValue;

                newRow.Elements.Add(curElement);
            }

            ListEntry insertedRow = feed.Insert(newRow);

            Console.WriteLine("Successfully inserted new row: \"{0}\"",
                              insertedRow.Content.Content);

            return(insertedRow);
        }
コード例 #23
0
        public AtomEntryCollection ObtenerListaLibros(SpreadsheetsService servicio)
        {
            var consulta = new SpreadsheetQuery();
            var libros   = servicio.Query(consulta);

            return(libros.Entries);
        }
コード例 #24
0
        /// <summary>
        /// Updates a single cell in the specified worksheet.
        /// </summary>
        /// <param name="service">an authenticated SpreadsheetsService object</param>
        /// <param name="entry">the worksheet to update</param>
        private static void UpdateCell(SpreadsheetsService service, WorksheetEntry entry)
        {
            AtomLink  cellFeedLink = entry.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);
            CellQuery query        = new CellQuery(cellFeedLink.HRef.ToString());

            Console.WriteLine();

            Console.Write("Row of cell to update? ");
            string row = Console.ReadLine();

            Console.Write("Column of cell to update? ");
            string column = Console.ReadLine();

            query.MinimumRow    = query.MaximumRow = uint.Parse(row);
            query.MinimumColumn = query.MaximumColumn = uint.Parse(column);

            CellFeed  feed = service.Query(query);
            CellEntry cell = feed.Entries[0] as CellEntry;

            Console.WriteLine();
            Console.WriteLine("Current cell value: {0}", cell.Cell.Value);
            Console.Write("Enter a new value: ");
            string newValue = Console.ReadLine();

            cell.Cell.InputValue = newValue;
            AtomEntry updatedCell = cell.Update();

            Console.WriteLine("Successfully updated cell: {0}", updatedCell.Content.Content);
        }
コード例 #25
0
        /// <summary>
        /// @kims 2016.08.09. Added second parameter to pass error message by reference.
        /// </summary>
        /// <returns>Null, if any error has been occured.</returns>
        public IDatabase GetDatabase(string name, ref string error)
        {
            Google.GData.Spreadsheets.SpreadsheetQuery query = new Google.GData.Spreadsheets.SpreadsheetQuery();

            // Make a request to the API and get all spreadsheets.
            SpreadsheetsService service = spreadsheetService as SpreadsheetsService;

            SpreadsheetFeed feed = service.Query(query);

            if (feed.Entries.Count == 0)
            {
                error = @"There are no spreadsheets in your docs.";
                return(null);
            }

            AtomEntry spreadsheet = null;

            foreach (AtomEntry sf in feed.Entries)
            {
                if (sf.Title.Text == name)
                {
                    spreadsheet = sf;
                }
            }

            if (spreadsheet == null)
            {
                error = @"There is no such spreadsheet with such title in your docs.";
                return(null);
            }

            return(new Database(this, spreadsheet));
        }
コード例 #26
0
        /// <summary>
        /// Retrieves and prints a list feed of the specified worksheet.
        /// </summary>
        /// <param name="service">an authenticated SpreadsheetsService object</param>
        /// <param name="entry">the worksheet to retrieve</param>
        /// <param name="reverseRows">true if the rows in the worksheet should
        /// be reversed when returned from the server</param>
        private static void RetrieveListFeed(SpreadsheetsService service, WorksheetEntry entry,
                                             bool reverseRows)
        {
            AtomLink listFeedLink = entry.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            Console.WriteLine();
            Console.WriteLine("This worksheet's list feed URL is:");
            Console.WriteLine(listFeedLink.HRef);

            ListQuery query = new ListQuery(listFeedLink.HRef.ToString());

            if (reverseRows)
            {
                query.OrderByPosition = true;
                query.Reverse         = true;
            }
            ListFeed feed = service.Query(query);

            Console.WriteLine();
            Console.WriteLine("Worksheet has {0} rows:", feed.Entries.Count);
            foreach (ListEntry worksheetRow in feed.Entries)
            {
                ListEntry.CustomElementCollection elements = worksheetRow.Elements;
                foreach (ListEntry.Custom element in elements)
                {
                    Console.Write(element.Value + "\t");
                }
                Console.WriteLine();
            }
        }
コード例 #27
0
        protected void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedIndex > -1)
            {
                spreadsheetName = listView1.SelectedItem.Text;
            }
            else
            {
                return;
            }
            if (spreadsheetName.Length > 0)
            {
                SpreadsheetsService GoogleExcelService;
                GoogleExcelService = new SpreadsheetsService("Spreadsheet-Abhishek-Test-App");
                GoogleExcelService.setUserCredentials("*****@*****.**", "Lucknow@");
                SpreadsheetQuery query  = new SpreadsheetQuery();
                SpreadsheetFeed  myFeed = GoogleExcelService.Query(query);
                foreach (SpreadsheetEntry mySpread in myFeed.Entries)
                {
                    if (mySpread.Title.Text == spreadsheetName)
                    {
                        WorksheetFeed wfeed = mySpread.Worksheets;
                        listView2.Items.Clear();

                        foreach (WorksheetEntry wsheet in wfeed.Entries)
                        {
                            string[] row = { wsheet.Title.Text, wsheet.Cols.ToString(), wsheet.Rows.ToString(), wsheet.Summary.Text };
                            System.Web.UI.WebControls.ListItem listItem = new System.Web.UI.WebControls.ListItem(wsheet.Title.Text);
                            listView2.Items.Add(listItem);
                        }
                    }
                }
            }
        }
コード例 #28
0
        static void Main(string[] args)
        {
            SpreadsheetsService myService = new SpreadsheetsService("ContenidoXXVICongreso");

            myService.setUserCredentials("*****@*****.**", "Ciruelazo#1");

            SpreadsheetQuery query = new SpreadsheetQuery();
            SpreadsheetFeed  feed  = myService.Query(query);

            Console.WriteLine("Your spreadsheets:");
            foreach (SpreadsheetEntry entry in feed.Entries)
            {
                Console.WriteLine(entry.Title.Text);
            }

            /*
             * AtomLink link = entry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);
             * WorksheetQuery query = new WorksheetQuery(link.HRef.ToString());
             * WorksheetFeed feed = myService.Query(query);
             * foreach (WorksheetEntry worksheet in feed.Entries)
             * {
             *  Console.WriteLine(worksheet.Title.Text);
             * }
             */
        }
コード例 #29
0
        public GoogleWorksheet(WorksheetEntry worksheet)
        {
            Service = (SpreadsheetsService)worksheet.Service;

            // Fetch the cell feed of the worksheet.
            CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
            CellFeed  cellFeed  = Service.Query(cellQuery);

            this.Columns = cellFeed.RowCount.IntegerValue;
            this.Rows    = cellFeed.ColCount.IntegerValue;

            // Iterate through each cell, printing its value.
            foreach (CellEntry cell in cellFeed.Entries)
            {
                Console.WriteLine(cell.Edited.DateValue);

                // Print the cell's address in A1 notation
                Console.WriteLine(cell.Title.Text);
                // Print the cell's address in R1C1 notation
                Console.WriteLine(cell.Id.Uri.Content.Substring(cell.Id.Uri.Content.LastIndexOf("/") + 1));
                // Print the cell's formula or text value
                Console.WriteLine(cell.InputValue);
                // Print the cell's calculated value if the cell's value is numeric
                // Prints empty string if cell's value is not numeric
                Console.WriteLine(cell.NumericValue);
                // Print the cell's displayed value (useful if the cell has a formula)
                Console.WriteLine(cell.Value);

                Console.ReadLine();
            }
        }
コード例 #30
0
        private void UpdateListFeed()
        {
            WorksheetEntry worksheet    = (WorksheetEntry)worksheetFeed.Entries[0];
            AtomLink       listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);
            ListQuery      listQuery    = new ListQuery(listFeedLink.HRef.ToString());

            listFeed = spreadsheetsService.Query(listQuery);
        }