Google Spreadsheet - 字符串值转换为日期?

时间:2015-07-23 13:56:55

标签: javascript google-sheets google-spreadsheet-api

伙计们我有一张带有column taskName的Google工作表,其类型为plain text。如果我在此5 jul下输入column之类的任何值,则会将其存储为5 jul

我使用类似于此的代码在工作表中添加值:

        var name = "5 Jul";
        var url = "&taskName=" + encodeURIComponent(name);
        var encodedString = encodeReservedCharacters(url);


        var htmlVal = "<html><script src='" + url + "?action=addName&groupId=" + groupId + "&prefix=addNameCallback" + "&" + encodedString + "'><'/script><'/html>";

        $("#checkscript").html(htmlVal);

        function encodeReservedCharacters(queryString) {
            var reservedCharWithEquivalentHexCode = {
                "(": "%28",
                ")": "%29",
                "/": "%2F",
                "*": "%2A",
                "'": "%27"
            };
            queryString = queryString.replace(/[()/*']/g, function(match) {
                return reservedCharWithEquivalentHexCode[match];
            });
            return queryString;
        };

groupId是我使用OAuth令牌的工作表ID 工作表已更新,但"5 Jul"代替7/5/2015,而是存储 var config = new MarketplaceWebServiceConfig { ServiceURL = ServiceURL }; var client = new MarketplaceWebServiceClient(AWSAccessKeyID, secretKey, appName, Version, config); var request = new GetReportRequest { Merchant = sellerID, ReportId = reportId }; var ms = new MemoryStream(); request.Report = ms; var response = client.GetReport(request); 。怎么解决这个?

1 个答案:

答案 0 :(得分:0)

我必须在新的Google表格突然解释为日期的单元格内容前加上一个勾号(&#39;),例如"2015-06"(现在我插入"'2015-06"