How to get all the filled data in the table in google sheets api? - api

Please tell me how in the Google Sheets API you can not manually get the range of the entire table located on a certain sheet.
I have a table in which the number of columns can change, but I still have to get information from it.
sheet = service.spreadsheets().values().get(
spreadsheetId=spreadsheet_id, range='???').execute()

You can you sheet.getDataRange() to get range of the visible data on your spreadsheet.

solution:
sheet = service.spreadsheets().values().get(
spreadsheetId=spreadsheet_id,
range='Sheet1',
majorDimension='ROWS').execute()

Related

Delete data from a sheet in google sheets with API - using Postman

I would like to erase all the data of a sheet in a google sheet
via the googlet sheets APIs: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/clear
Unfortunately I can not select the id of my sheet.
I used the proposed method: POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetid}/values/{range}: clear
but it only removes the data from my first sheet.
How can I put the id of my other leaves in the method?
My google sheets ID
My first sheets in my google sheets
ID of my second sheets
My second sheets in my google sheets
From your reply, the request of "Method: spreadsheets.values.clear" is as follows.
POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:clear
spreadsheetId : The spreadsheet the updates were applied to.
range: The range (in A1 notation) that was cleared. (If the request was for an unbounded range or a ranger larger than the bounds of the sheet, this will be the actual range that was cleared, bounded to the sheet's limits.)
In this case, it is not required to use the sheet ID. The sheet name is used.
From your showing images, it seems that the sheet names of your 1st and 2nd sheet are Feuille 1 and Feuille 2, respectively. For example, when you want to clear 2nd sheet of Feuille 2, please use the following request.
POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/Feuille%202:clear
Note:
For example, when you want to retrieve the sheet names from a Google Spreadsheet, you can use "Method: spreadsheets.get". Ref
Reference:
Method: spreadsheets.values.clear

Referencing a sheet by index number

I've got a LibreOffice Calc spreadsheet that I use to keep track of my accounts receivable at work. Each sheet lists invoices and their status (paid, unpaid, etc) as well as info about each invoice. I'm trying to create a Summary sheet that lists certain data from each sheet. Creating the sheet manually is easy, but I'm trying to "automate" the process. I want the summary page to auto-update if I add a new sheet (or remove one) as I add and remove accounts to the file.
I know that LibreOffice assigns each sheet an index number that I could refer to in some sort of formula, but I cannot find a function that I can use to refer to that index number when getting a value from a cell within it. One would expect that a function like Sheet(2) would reference the second sheet, but, alas, that is not so!
I've tried using the indirect and address functions without success, but I'm not sure if I'm not understanding these functions or if they're not appropriate for what I'm trying to accomplish.
This has been a missing piece in Calc for a long time. The preferred solution is to write a user-defined function. Spreadsheet formulas do not access sheets by index number but Basic can.
The following function is from https://ask.libreoffice.org/en/question/16604/how-do-i-access-the-current-sheet-name-in-formula-to-use-in-indirect/.
Function SheetName(Optional nSheet)
If IsMissing(nSheet) Then
SheetName = ThisComponent.getCurrentController().getActiveSheet().getName()
Else
SheetName = ThisComponent.getSheets().getByIndex(nSheet-1).getName()
EndIf
End Function
Then get a relative address of the first sheet cell A1 like this.
=ADDRESS(1,1,4,,SHEETNAME(1))
A slightly different function is given at https://forum.openoffice.org/en/forum/viewtopic.php?f=9&t=49799.

Transferring information from input sheet to master sheet

I am trying to move data from one workbook 'input worksheet' to another workbook 'master workbook'. Both sheets are in the same file and if possible, it would be great if both files didn't have to be open at the same time in order to transfer the data but the master workbook would autosave once the data was transferred across. Links to images of the files below to make it easier to understand what I am trying to do.
The data in the input worksheet is in row 6, columns A-J with each user inputting details of the tasks they get asked to complete. I would like when a button is clicked, the data from the input worksheet is transferred into row 2, columns B-K in the master workbook so that each time a new task is entered and transferred across, it appears in the row below (so that it can be pivoted later, etc.).
http://i.stack.imgur.com/b2cyI.jpg - input sheet
http://i.stack.imgur.com/JZr0a.jpg - master sheet
Use the macros here to get the last row in the master sheet.
Then simply write the values from the input sheet to the corresponding cell in the master sheet.
That is all. This is how you refer cells:
tbl_master.cells(1,3) = tbl_input.cells(3,5).value
Make sure that the row in the tbl_input is a variable, coming from the function, calculating the last row. Give it a try!
Edit:
This is what I use for last row:
Public Function last_row_with_data(ByVal lng_column_number As Long, shCurrent As Variant) As Long
last_row_with_data = shCurrent.Cells(Rows.Count, lng_column_number).End(xlUp).Row
End Function
If you want to find the last row of column B of sheet "tbl_main" you call it like this:
last_row_with_data(2,tbl_main)
Edit2:
Change the names of your sheets here, and reference them by their names.
In order to get this window, select the sheet on the left and press F4.

I need to generate new workbooks using existing sheets that I will autopop with data

I have two sheets on my template. Sheet one contains a SKU in column A and a descr. in column B
On sheet 2, I have a pre-written template that has generic SKU and Description. That means under the item sku, it says D999 and under the description it says xxx.
I want to replace "999" with the value in A2 on my first sheet, but the 999 is in multiple columns through the sheet. Next, I want to replace the "xxx" with the data in B2 from sheet 1. I can't seem to find a VBA code that will do this specifically.
Lastly, once the find and replaces are done, I need to have it save me a new workbook using sheet2, in the same format, and name it as the value in A4 on sheet 2. I think you should be able to find the workbook here My Workbook
Basically, I want to be able to enter a bulk amount of new SKUs and Description, and be able to generate a new workbook for each SKU I enter. Right now I have 78 waiting to have sheets made.
In the cell to the right of the cells where you want to type in the SKU, add the following formula: =Match(A2, LookupsheetName!B:B,0). This will return the row the SKU was found on. In the next cell to the right use the Index function: =Index(LookupSheetName!A1:B1000, B2, 0). This will bring the label in column B to the current page. The Match function locates the row the SKU was found on.
Try these for looking up the information, because they are more efficient than VLookups.
The code for copying a worksheet to another workbook can be created using the Macro recorder on the Developer tab. Turn the recorder on then do the steps to manually move/copy to another workbook. When done, open the VBA editor and figure out how to save the workbook to a new name each time.
Good luck.

I need to automate this Excel file the best I can

I have an Excel sheet that I created. For this sheet it pulls in a data feed on two of the sheets. The data feed has a parameter which I populate from a Drop Down that is fed off of another sheet. I'm trying to automate this process. I want to be able to have the file run through each one of the ID's (the parameter), run the data feed, save the excel sheet, run the next ID save and so on until it goes through the list. Can someone please please help me with this? I'm new to VBA.
1) you need a list of your IDs. I like Named Ranges, so mine is named ID_List
2) Loop thru your list
dim r as range
for each r in [ID_List]
'do yer stuff here
'what needs to be done with the value **r.value**???
'how do you want to save the file each time???
next
Need some specific answers!