在不知道其范围的情况下阅读电子表格 [英] Read spreadsheet without knowing its range

查看:90
本文介绍了在不知道其范围的情况下阅读电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不知道电子表格范围的情况下阅读电子表格.在C#中有可能吗?否则我必须指定范围,直到将值插入表中?

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;

推荐答案

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

Sheet1引用Sheet1中的所有单元格.

Sheet1 refers to all the cells in Sheet1.

因此,如果您真的想要所有单元格,则只需使用它,而无需尾随!.如果要查找大小而不是获取值,则可能需要spreadsheets.get而不是spreadsheets.values.get方法.

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.

这篇关于在不知道其范围的情况下阅读电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆