使用C#在Google Spreadsheet中创建公式时添加了撇号 [英] Apostrophe is added when creating formula in Google Spreadsheet using C#

查看:53
本文介绍了使用C#在Google Spreadsheet中创建公式时添加了撇号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我通过C#在Google表格中创建公式时,该公式前面会带有撇号:

When I create a formula in Google Sheets via C#, the formula gets prepended with an apostrophe like so:

'=SUM(B3:B5)

开头带有撇号,该公式被视为字符串,因此它没有执行应做的事情.你能帮我吗?下面是我的代码.

With that apostrophe in the beginning, the formula is treated as string so it does not do what it is supposed to do. Can you help? Below is my code.

        var formula1 = "=SUM(B3:B5)";
        var formula2 = "=SUM(C3:C5";
        var formula3 = "=MAX(D3:D5)";

        List<object> list1 = new List<object>() { "Item", "Cost", "Stocked", "Ship Date" };
        List<object> list2 = new List<object>() { "Wheel", "$20.50", "4", "3/1/2016" };
        List<object> list3 = new List<object>() { "Door", "$15", "2", "3/15/2016" };
        List<object> list4 = new List<object>() { "Engine", "$100", "1", "30/20/2016" };
        List<object> list5 = new List<object>() { "Totals", formula1, formula2, formula3 };
        IList<IList<Object>> list = new List<IList<Object>>() { list1, list2, list3, list4, list5 };

        ValueRange VRange = new ValueRange();
        VRange.Range = range;
        VRange.Values = list;

        SpreadsheetsResource.ValuesResource.AppendRequest ar = service.Spreadsheets.Values.Append(VRange, spreadsheetId,range);
        ar.ValueInputOption = SpreadsheetsResource.ValuesResource.AppendRequest.ValueInputOptionEnum.RAW;
        var response2 = ar.Execute();

谢谢.

推荐答案

我明白了.您只需要像这样将"RAW"更改为"USERENTERED"

I got it. You just need to change the "RAW" to "USERENTERED" like this

ar.ValueInputOption = SpreadsheetsResource.ValuesResource.AppendRequest.ValueInputOptionEnum.USERENTERED;

这篇关于使用C#在Google Spreadsheet中创建公式时添加了撇号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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