Read spreadsheet without knowing its range

夙愿已清 提交于 2019-12-08 04:49:58

问题


I would like to read a spreadsheet without knowing its range. Is that possible in C#? Or else I have to specify the range till the values are inserted in the sheet?

These things are dynamic in my requirement. The range can be at any limit so my code need to read the entered data from my sheet.

// Create Google Sheets API service.

SheetsService SheetsService = GetSheetsService(); 

// Here is my doubt. 
// I have specified only the sheet name 
// but I dont know the range which could be dynamic

var range = "Sheet3!"; 

SpreadsheetsResource.ValuesResource.GetRequest request = 
    SheetsService.Spreadsheets.Values.Get(SpreadSheetID, range); 

var response = request.Execute(); 
return response;

回答1:


The documentation for A1 notation (which is what the range is expressed in) includes:

Sheet1 refers to all the cells in Sheet1.

So if you really want all the cells, just use that, without a trailing !. If you want to find out the size rather than getting the values, you may want the spreadsheets.get rather than spreadsheets.values.get method.



来源:https://stackoverflow.com/questions/47407275/read-spreadsheet-without-knowing-its-range

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!