Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 199031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:59:18+00:00 2026-05-11T16:59:18+00:00

Yesterday i installed C# 3.5 and today when read topic here of Accessing Google

  • 0

Yesterday i installed C# 3.5 and today when read topic here of “Accessing Google Spreadsheets with C# using Google Data API”, and decided to try it out.

So i decided to write a example, that:
1) get data feed of first Worksheet of first Spreadsheet, that name contains string segment that user inserted
2) fill grid with data

Well i got to part, fill 2 dimensional array or lists of list with spreadsheet value data. I am stuck at finding a control to put data into, and dynamically generating it, as i don’t know rows or columns of worksheet beforehand.

My intuition says, i could just change List> with Dataset, and start trying out different controls, that IntelliSense throws at me. I am aware that i should read a book first, but i was to impatient not try it out first.

Xaml

<DockPanel Background="LightSteelBlue">

    <!-- Standard input -->
    <DockPanel DockPanel.Dock="Top" Margin="5">
        <TextBlock Margin="10,0,5,0" VerticalAlignment="Center">Username:</TextBlock>
        <TextBox x:Name="username" Width="120" Padding="5,0,5,0" Text="username@gmail.com" />
        <TextBlock Margin="10,0,5,0" VerticalAlignment="Center">Password:</TextBlock>
        <TextBox x:Name="password" Width="120" Padding="5,0,5,0" Text="password" />
        <TextBlock Margin="10,0,5,0" VerticalAlignment="Center">Workbook:</TextBlock>
        <TextBox x:Name="workbookname" Width="120" Padding="5,0,5,0" Text="name" />
        <Button x:Name="getData" Margin="5,0,0,0" Padding="5,0,5,0" Content="Get _Data" Click="getData_Click" />
    </DockPanel>

    <!-- Grid display -->
    <ListBox Name="lb2"/>

</DockPanel>

And c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using System.Collections;
using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Spreadsheets;

namespace getGoogleDocsSpreadsheetData
{
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private bool RunSample(
            String g_username,
            String g_password,
            String g_spreadsheetname
        ){
            SpreadsheetsService service = new SpreadsheetsService("Margus-stackoverflow_example-1");
            service.setUserCredentials(g_username, g_password);
            CellFeed cfeed = null;

            try {
                //get CellFeed of first Worksheet of first Spreadsheet, that contains _spreadsheetname
                cfeed = ((CellFeed)service.Query(new CellQuery(
                    ((WorksheetEntry)(service.Query(new WorksheetQuery(
                        ((SpreadsheetEntry)(
                            from fe in service.Query(new SpreadsheetQuery()).Entries
                            where fe.Title.Text.Contains(g_spreadsheetname)
                            select fe
                        ).First()).Links.FindService(
                            GDataSpreadsheetsNameTable.WorksheetRel,
                            null
                        ).HRef.ToString())).Entries.First())
                    ).Links.FindService(
                        GDataSpreadsheetsNameTable.CellRel,
                        null
                    ).HRef.ToString()))
                );

                /* get data to array
                string[,] values = new string
                    [(from sr in cfeed.Entries select ((CellEntry)sr).Cell.Row).Max()+1
                    ,(from sr in cfeed.Entries select ((CellEntry)sr).Cell.Column).Max()+1];

                foreach (CellEntry curCell in cfeed.Entries)
                    values[curCell.Cell.Row,curCell.Cell.Column] = curCell.Cell.Value;
                 */

                /* get data to list of list of string */
                List<List<string>> lists = new List<List<string>>();

                for (int i = 0; i < 1+ (
                    from sr in cfeed.Entries 
                    select ((CellEntry)sr).Cell.Row).Max(); i++
                ){
                    List<string> x = new List<string>();
                    for (int j = 0; j < 1+ (
                        from sr in cfeed.Entries 
                        select ((CellEntry)sr).Cell.Column).Max(); j++
                    )
                    x.Add(default(string));

                    lists.Add(x);
                }

                foreach (CellEntry curCell in cfeed.Entries)
                    (lists[(int)curCell.Cell.Row])[(int)curCell.Cell.Column] = curCell.Cell.Value;

                //fill datagrid
                this.lb2.ItemsSource = lists;              
            } catch (Exception e){
                System.Console.WriteLine("I exeeded failing!\n" + e.StackTrace);
                return false;
            }

            return true;
        }

        private void getData_Click(object sender, RoutedEventArgs e)
        {
            RunSample(
                this.username.Text,
                this.password.Text,
                this.workbookname.Text);
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:59:18+00:00Added an answer on May 11, 2026 at 4:59 pm

    I’ve used this from the WPFToolkit:

    <my:DataGrid Margin="0,29,0,0" Name="dataGridView" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" AlternatingRowBackground="AliceBlue" ItemsSource="{Binding Path=.}" CanUserResizeRows="False" ClipboardCopyMode="IncludeHeader" IsReadOnly="True" IsTabStop="True" AutoGeneratedColumns="dataGridView_AutoGeneratedColumns" />
    

    With some code behind to populate it:

    private DataTable dataTable;
    
    public Constructor()
    {
        ....
        this.dataTable = new DataTable();
    
        dataGridView.DataContext = dataTable;
        ....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the latest indy snapshot (installed yesterday) and newest SSL libraries. When trying
I installed Ruby and Ruby on Rails yesterday on Vista 32bit using the directions
I just installed macvim yesterday and I installed vim latex today. One of the
I have no idea what happened. I was using it normally just yesterday, today
Yesterday I installed Delphi XE2 using the download option, so I guess the installed
yesterday I watched Google IO Talk about NFC and today I'm trying to do
i'm using Elcipse+PyDev and Pyscripter sometimes for Python 2.7 Yesterday i installed PyTables from
I have installed Nuget 1.2 yesterday, and today, while I was trying to install
Yesterday I was working using MySQL installed on my computer. I downloaded xampp, so
I installed Django for the first time yesterday and trying it out in earnest

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.