/// <summary>
        /// Loads all the information from the selected worksheet
        /// </summary>
        /// <param name="worksheet"></param>
        /// <returns></returns>
        ///
        /// <summary>
        /// Loads all the information from the selected worksheet
        /// </summary>
        /// <param name="worksheet"></param>
        /// <returns></returns>
        public static WorksheetData LoadAllWorksheetInformation(this GS2U_Worksheet worksheet)
        {
            ListFeed      feed       = LoadListFeedWorksheet(worksheet);
            WorksheetData returnData = new WorksheetData();

            foreach (ListEntry row in feed.Entries)
            {
                string  rowTitle = row.Title.Text;
                RowData rowData  = new RowData(rowTitle);

                foreach (ListEntry.Custom element in row.Elements)
                {
                    rowData.cells.Add(new CellData(element.Value, element.LocalName, rowTitle));
                }

                returnData.rows.Add(rowData);
            }

            return(returnData);
        }
Example #2
0
        /// <summary>
        /// Loads a public spreadsheet and worksheet(worksheets start at 1 not 0)
        /// </summary>
        /// <param name="spreadsheetID"></param>
        /// <param name="worksheetNumber"></param>
        /// <returns></returns>
        public WorksheetData LoadPublicWorkSheet(string spreadsheetID, int worksheetNumber)
        {
            SecurityPolicy.Instate();

            SpreadsheetsService publicService = new SpreadsheetsService("Unity");

            ListQuery listQuery = new ListQuery("https://spreadsheets.google.com/feeds/list/" + spreadsheetID + "/" + worksheetNumber + "/public/values");

            ListFeed      feed       = publicService.Query(listQuery) as ListFeed;
            WorksheetData returnData = new WorksheetData();

            List <string> titles = GetColumnTitles(feed);

            if (titleRowActual > 0)
            {
                //remove all rows above the title row
                for (int i = 0; i <= titleRowActual; i++)
                {
                    feed.Entries.RemoveAt(0);
                }
            }

            foreach (ListEntry row in feed.Entries)
            {
                string  rowTitle = row.Title.Text;
                RowData rowData  = new RowData(rowTitle);

                int rowId = 0;
                foreach (ListEntry.Custom element in row.Elements)
                {
                    rowData.cells.Add(new CellData(element.Value, titles[rowId], rowTitle));
                    rowId++;
                }

                returnData.rows.Add(rowData);
            }

            return(returnData);
        }