// 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(); } }
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); } }
public AtomEntryCollection ObtenerListaLibros(SpreadsheetsService servicio) { var consulta = new SpreadsheetQuery(); var libros = servicio.Query(consulta); return(libros.Entries); }
private void findSpreadsheet(Boolean debug_flag = false) { SpreadsheetQuery query = new SpreadsheetQuery(); query.Title = spreadsheetname; if (debug_flag) { Console.WriteLine("Trying to find spreadsheet with name " + spreadsheetname); } SpreadsheetFeed feed = service.Query(query); if (feed.Entries.Count > 0) { spreadsheet = (SpreadsheetEntry)feed.Entries[0]; if (debug_flag) { Console.WriteLine("Found spreadsheet with name " + spreadsheet.Title.Text); } } else { if (debug_flag) { Console.WriteLine("No Spreadsheet with name " + spreadsheetname + " could be found!!!"); } throw new ArgumentNullException("Spreadsheet with name " + spreadsheetname + " not found!!!"); } }
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); * } */ }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { listView2.Clear(); if (listView1.SelectedItems.Count == 0) { return; } var documentTitle = this.listView1.SelectedItems[0].SubItems[0].Text; var query = new SpreadsheetQuery(); query.Title = documentTitle; //looking for a exact worksheet of the given selected title. Returns 1 match. var selectedSpreadsheet = (SpreadsheetEntry)App.Service.Query(query).Entries[0]; //retrieve all worksheets available in the selected spreadsheet. var allWorksheetsFeed = selectedSpreadsheet.Worksheets; foreach (var worksheet in allWorksheetsFeed.Entries) { var listItem = new ListViewItem(worksheet.Title.Text) { Tag = worksheet }; this.listView2.Items.Add(listItem); } }
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); }
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"); } }
private void WorksheetListForm_Load(object sender, EventArgs e) { //Check if user/pass are null. If the are null, show the login form. if (string.IsNullOrEmpty(App.CurrentUser) || string.IsNullOrEmpty(App.CurrentPassword)) { var loginForm = new LoginForm(); loginForm.Show(); this.Close(); return; } // Instantiate a SpreadsheetQuery object to retrieve spreadsheets. SpreadsheetQuery query = new SpreadsheetQuery(); // Make a request to the API and get all spreadsheets. SpreadsheetFeed feed = App.Service.Query(query); if (feed.Entries.Count == 0) { MessageBox.Show("There are no spreadsheets created by this user.", "Google Spreadsheets API", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } //iterate over each worksheet found and fill the list view with title, author and link foreach (var entry in feed.Entries) { ListViewItem item = new ListViewItem(new string[] { entry.Title.Text, entry.Authors[0].Name, entry.AlternateUri.Content }); this.listView1.Items.Add(item); } }
public List <List <RoomData> > GetSpreadSheetData() { UnsafeSecurityPolicy.Instate(); if (_RefreshToken == "" && _AccessToken == "") { Init(); return(null); } Auth(); SpreadsheetQuery query = new SpreadsheetQuery(); // Make a request to the API and get all spreadsheets. SpreadsheetFeed feed = service.Query(query); if (feed.Entries.Count == 0) { Debug.Log("There are no spreadsheets in your docs."); return(null); } AccessSpreadsheet(GetSheetIdByDay(DateTime.Today.DayOfWeek), feed, listData); return(listData); }
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); } } } } }
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); }
private void button1_Click(object sender, EventArgs e) { App.Service.setUserCredentials(this.txtUser.Text, this.txtPass.Text); // Instantiate a SpreadsheetQuery object to retrieve spreadsheets. SpreadsheetQuery query = new SpreadsheetQuery(); // Make a request to the API and get all spreadsheets. SpreadsheetFeed feed = App.Service.Query(query); if (feed.Entries.Count == 0) { MessageBox.Show("There are no spreadsheets created by this user.", "Google Spreadsheets API", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } App.CurrentUser = this.txtUser.Text; App.CurrentPassword = this.txtPass.Text; var wksListForm = new WorksheetListForm(); wksListForm.Show(); this.Close(); }
//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); }
// 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)); }
/// <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)); }
private void EnsureSpreadsheetFeed() { if (Application.sf == null) { SpreadsheetQuery query = new SpreadsheetQuery(); Application.sf = service.Query(query); } }
public static AtomEntryCollection GetSpreadsheetList(SpreadsheetsService zSpreadsheetService) { // get all spreadsheet names var query = new SpreadsheetQuery(); var feed = zSpreadsheetService.Query(query); return(feed.Entries); }
public SpreadsheetIO(string username, string password) { _userName = username; _password = password; _service = new SpreadsheetsService("MySpreadsheetIntegration-v1"); _service.setUserCredentials(_userName, _password); _query = new SpreadsheetQuery(); _feed = _service.Query(_query); }
/// <summary> /// loads a spreadsheet using its name, if 2 or more spreadsheets share a name will load the first found instance /// </summary> /// <param name="manager"></param> /// <param name="spreadSheetName"></param> /// <returns></returns> public static GS2U_SpreadSheet LoadSpreadSheet(this SpreadSheetManager manager, string spreadSheetName) { SpreadsheetQuery query = new SpreadsheetQuery(); query.Title = spreadSheetName; SpreadsheetFeed feed = SpreadSheetManager.service.Query(query) as SpreadsheetFeed; return(new GS2U_SpreadSheet((SpreadsheetEntry)feed.Entries[0])); }
/// <summary> /// Load a spreadsheet from its unique id, usefully if 2 or more spreadsheets have the same name /// </summary> /// <param name="manager"></param> /// <param name="spreadSheetID"></param> /// <param name="isSheetId"></param> /// <returns></returns> public static GS2U_SpreadSheet LoadSpreadSheet(this SpreadSheetManager manager, string spreadSheetID, bool isSheetId) { SpreadsheetQuery query = new SpreadsheetQuery(); query.Uri = new Uri("https://spreadsheets.google.com/feeds/spreadsheets/private/full/" + spreadSheetID); SpreadsheetFeed feed = SpreadSheetManager.service.Query(query) as SpreadsheetFeed; return(new GS2U_SpreadSheet((SpreadsheetEntry)feed.Entries[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>()); }
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]; }
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); }
static SpreadsheetFeed GetSpreadsheetFeed() { GOAuth2RequestFactory requestFactory = RefreshAuthenticate(); _spreadsheetService = new SpreadsheetsService("SpreadSheet"); _spreadsheetService.RequestFactory = requestFactory; SpreadsheetQuery query = new SpreadsheetQuery(); return(_spreadsheetService.Query(query)); }
public static MTSpreadsheet GetSpreadsheet(string title, GoogleParams p) { SpreadsheetsService service = GetService(p); SpreadsheetQuery query = new SpreadsheetQuery(); query.Title = title; SpreadsheetFeed feed = service.Query(query); SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[0]; return(new MTSpreadsheet(spreadsheet, service)); }
/// <summary> /// Prints a list of all the user's spreadsheets, and the /// list of worksheets that each spreadsheet contains. /// </summary> /// <param name="service">an authenticated SpreadsheetsService object</param> private static void PrintAllSpreadsheetsAndWorksheets(SpreadsheetsService service) { SpreadsheetQuery query = new SpreadsheetQuery(); SpreadsheetFeed feed = service.Query(query); Console.WriteLine("Your spreadsheets:"); foreach (SpreadsheetEntry entry in feed.Entries) { Console.WriteLine("Spreadsheet: {0}", entry.Title.Text); PrintAllWorksheets(service, entry); } }
public static List <Spreadsheet> ListAll() { SpreadsheetsService service = new SpreadsheetsService("ClearCanvas-Workstation-1.0"); service.setUserCredentials("jresnick", "bl00b0lt"); SpreadsheetQuery query = new SpreadsheetQuery(); SpreadsheetFeed feed = service.Query(query); return(CollectionUtils.Map <SpreadsheetEntry, Spreadsheet, List <Spreadsheet> >( feed.Entries, delegate(SpreadsheetEntry entry) { return new Spreadsheet(service, entry); })); }
public List <TDataRow> ReadAll <TDataRow>(String documentName, String sheetTitle) where TDataRow : GdataRow, new() { SpreadsheetQuery sheetQuery = new SpreadsheetQuery(); SpreadsheetFeed sheetFeed = AuthorisedSpreadsheetsService.Query(sheetQuery); AtomEntry affiliates = (from x in sheetFeed.Entries where x.Title.Text.Contains(documentName) select x).First(); // Get the first Worksheet... AtomLink sheetLink = affiliates.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null); WorksheetQuery workSheetQuery = new WorksheetQuery(sheetLink.HRef.ToString()); WorksheetFeed workSheetFeed = AuthorisedSpreadsheetsService.Query(workSheetQuery); AtomEntry affiliateSheet = workSheetFeed.Entries.First(s => s.Title.Text.Equals(sheetTitle, StringComparison.InvariantCultureIgnoreCase)); // Get the cells... UInt32 startRow = 2; AtomLink cellLink = affiliateSheet.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null); CellQuery cellQuery = new CellQuery(cellLink.HRef.ToString()) { MinimumRow = startRow, }; CellFeed cellFeed = AuthorisedSpreadsheetsService.Query(cellQuery); List <TDataRow> table = new List <TDataRow>(); TDataRow row = null; foreach (CellEntry currentCell in cellFeed.Entries) { if (currentCell.Column == 1) { if (currentCell.Value.Equals("-end-", StringComparison.InvariantCultureIgnoreCase)) { break; } row = new TDataRow { RowNbr = currentCell.Row, Service = AuthorisedSpreadsheetsService, CellLink = cellLink }; table.Add(row); } if (currentCell.Column > row.LastColumn) { continue; } row.SetValue(currentCell); } return(table); }
public static Spreadsheet GetByTitle(string title) { SpreadsheetsService service = new SpreadsheetsService("ClearCanvas-Workstation-1.0"); service.setUserCredentials("jresnick", "bl00b0lt"); SpreadsheetQuery query = new SpreadsheetQuery(); query.Title = title; SpreadsheetFeed feed = service.Query(query); return(feed.Entries.Count > 0 ? new Spreadsheet(service, (SpreadsheetEntry)feed.Entries[0]) : null); }