从C#中的智能表中检索行数据

Dan*_*rex 5 c# smartsheet-api smartsheet-c#-sdk-v1

我希望能够从C#中的特定列中检索数据行作为列表.因此,如果有一列人物高度,它会列出列表中的那些高度.可能还列出x,y值表示特定日期的苹果数量.

我查看了有关API信息的示例,但无法找到有关如何执行此操作的示例 - 它们主要包括创建文件夹,用户或列出文件夹或工作表或在智能表等上输入信息,但实际上没有实际获取数据.

以下是我看过的代码:https : //github.com/smartsheet-platform/samples/tree/master/c%23 https://github.com/smartsheet-platform/smartsheet-csharp-sdk

但我实际上想把数据作为一个列表拉出来,然后在C#中为最终用户处理它,所以我不想把它放回到智能表中.

是唯一的方法来使用API​​下载文件作为Excel表格并从那里开始?如果可能的话,我真的想跳过这一步吗?

我应该补充一点,我想使用C#SDK来做到这一点.

我认为我需要输入的具体代码(我认为)是为了得到表格.

// Set the Access Token
Token token = new Token();
token.AccessToken = "INSERT_YOUR_TOKEN_HERE";
long id = "INSERT SHEET ID HERE";


// Use the Smartsheet Builder to create a Smartsheet
SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(
token.AccessToken).Build();

//Code to get sheet
smartsheet.Sheets().GetSheet(long id, **IEnumerable<ObjectInclusion?includes**).Rows();
Run Code Online (Sandbox Code Playgroud)

这是我不确定他们需要的最后一个参数.它在GetSheet方法中说:

Sheet GetSheet(长id,IEnumerable包含)

这是ObjectInclusion枚举的链接 - http://smartsheet-platform.github.io/smartsheet-csharp-sdk/html/T_Smartsheet_Api_Models_ObjectInclusion.htm

Bre*_*ett 5

这是一个在每张纸上打印单元格数据的示例.

        // Set the Access Token
        Token token = new Token();
        token.AccessToken = "YOUR_TOKEN";

        // Use the Smartsheet Builder to create a Smartsheet
        SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(token.AccessToken).Build();

        // Gets just a list of sheets (not the actual data in the sheet)
        IList<Sheet> homeSheets = smartsheet.Sheets().ListSheets();
        foreach (Sheet tmpSheet in homeSheets)
        {
            Console.WriteLine("========== New Sheet: " + tmpSheet.Name);
            // Get the sheet with the data
            Sheet sheet = smartsheet.Sheets().GetSheet((long)tmpSheet.ID, new ObjectInclusion[] { ObjectInclusion.DATA, ObjectInclusion.COLUMNS });

            int rowCount = 0;
            foreach (Row tmpRow in sheet.Rows)
            {
                Console.Write(rowCount++ + ": ");
                foreach (Cell tmpCell in tmpRow.Cells)
                {
                    Console.Write(tmpCell.Value + "|");
                }
                Console.WriteLine();
            }
        }
Run Code Online (Sandbox Code Playgroud)

要回答其他一些问题:

是唯一的方法来使用API​​下载文件作为Excel表格并从那里开始?如果可能的话,我真的想跳过这一步吗?

C#SDKAPI都支持检索部分或全部的片数据的能力.您不需要将工作表下载为Excel文件,以便处理工作表中的数据.

我不确定他们需要什么.它在GetSheet方法中说:Sheet GetSheet(long id,IEnumerable <ObjectInclusion>)

一个IEnumerable的仅仅是一个集合,是迭代.您可以将任何集合用于实现此接口的第二个参数.该集合应包含其列表中的ObjectInclusion项.在我的例子中,我使用了一个数组,因为它实现了一个实现IEnumerable 的IList.