示例#1
0
 public IActionResult AppendColumnLine(AppendColumnDto column)
 {
     return(CheckSheetExist(column.Sheetname, () =>
     {
         var result = SheetsService.AppendColumnLine(
             GoogleSheetsApi.SpreadSheetId,
             SheetRange.ToRange(column.Sheetname, column.Range),
             request => { },
             column.Line);
         return Ok(result);
     }));
 }
示例#2
0
 public IActionResult GetRowLine(string sheetname, string range)
 {
     return(CheckSheetExist(sheetname, () =>
     {
         var result = SheetsService.ReadRange(GoogleSheetsApi.SpreadSheetId,
                                              SheetRange.ToRange(sheetname, range),
                                              r =>
         {
             r.MajorDimension = SpreadsheetsResource.ValuesResource.GetRequest.MajorDimensionEnum.ROWS;
         });
         return Ok(result);
     }));
 }
示例#3
0
 public IActionResult AppendRange(AppendRangeDto range)
 {
     return(CheckSheetExist(range.Sheetname, () =>
     {
         var result = SheetsService.AppendRange(
             GoogleSheetsApi.SpreadSheetId,
             SheetRange.ToRange(range.Sheetname, range.Range),
             request =>
         {
             request.InsertDataOption = Google.Apis.Sheets.v4.SpreadsheetsResource.ValuesResource.AppendRequest.InsertDataOptionEnum.INSERTROWS;
         },
             range.Values);
         return Ok(result);
     }));
 }
示例#4
0
        public async Task <string> ClearSheet()
        {
            Response.Headers.Add("Cache-Control", "no-cache");
            string    response       = string.Empty;
            string    imagesFolderId = null;
            string    accountName    = this._httpContextAccessor.HttpContext.Request.Headers[DriveImportConstants.VTEX_ACCOUNT_HEADER_NAME];
            FolderIds folderIds      = await _driveImportRepository.LoadFolderIds(accountName);

            if (folderIds != null)
            {
                imagesFolderId = folderIds.ImagesFolderId;
                ListFilesResponse spreadsheets = await _googleDriveService.ListSheetsInFolder(imagesFolderId);

                if (spreadsheets != null)
                {
                    SheetRange sheetRange = new SheetRange();
                    sheetRange.Ranges = new List <string>();
                    sheetRange.Ranges.Add($"A2:Z{DriveImportConstants.DEFAULT_SHEET_SIZE}");

                    foreach (GoogleFile sheet in spreadsheets.Files)
                    {
                        response = response + " - " + _googleDriveService.ClearSpreadsheet(sheet.Id, sheetRange).Result;
                    }
                }
                else
                {
                    response = "null sheet";
                }
            }
            else
            {
                response = "null folderIds";
            }

            return(response);
        }
示例#5
0
        /// <summary>
        /// Author:         Josephine Gad
        /// Date Created:   17/Mar/2013
        /// Description:    Sheet to be used in Excel export
        /// ------------------------------------------------
        /// </summary>
        /// <returns></returns>
        public static List <SheetRange> SheetColumn()
        {
            List <SheetRange> list = new List <SheetRange>();
            SheetRange        item = new SheetRange();

            item.Number = 1;
            item.Letter = "A";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 2;
            item.Letter = "B";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 3;
            item.Letter = "C";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 4;
            item.Letter = "D";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 5;
            item.Letter = "E";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 6;
            item.Letter = "F";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 7;
            item.Letter = "G";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 8;
            item.Letter = "H";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 9;
            item.Letter = "I";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 10;
            item.Letter = "J";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 11;
            item.Letter = "K";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 12;
            item.Letter = "L";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 13;
            item.Letter = "M";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 14;
            item.Letter = "N";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 15;
            item.Letter = "O";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 16;
            item.Letter = "P";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 17;
            item.Letter = "Q";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 18;
            item.Letter = "R";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 19;
            item.Letter = "S";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 20;
            item.Letter = "T";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 21;
            item.Letter = "U";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 22;
            item.Letter = "V";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 23;
            item.Letter = "W";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 24;
            item.Letter = "X";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 25;
            item.Letter = "Y";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 26;
            item.Letter = "Z";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 27;
            item.Letter = "AA";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 28;
            item.Letter = "AB";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 29;
            item.Letter = "AC";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 30;
            item.Letter = "AD";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 31;
            item.Letter = "AE";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 32;
            item.Letter = "AF";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 33;
            item.Letter = "AG";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 34;
            item.Letter = "AH";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 35;
            item.Letter = "AI";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 36;
            item.Letter = "AJ";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 37;
            item.Letter = "AK";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 38;
            item.Letter = "AL";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 39;
            item.Letter = "AM";
            list.Add(item);

            item        = new SheetRange();
            item.Number = 40;
            item.Letter = "AN";
            list.Add(item);

            return(list);
        }