Changes for page 2 Script
Last modified by Devin Chen on 2026/03/10 10:53
From version 17.1
edited by Devin Chen
on 2026/03/05 15:30
on 2026/03/05 15:30
Change comment:
There is no comment for this version
To version 9.1
edited by Devin Chen
on 2025/11/05 09:27
on 2025/11/05 09:27
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
-
Attachments (0 modified, 0 added, 8 removed)
Details
- Page properties
-
- Parent
-
... ... @@ -1,1 +1,1 @@ 1 -V-Net 2\.0.Demo.WebHome1 +V-BOX.V-Net.Training.WebHome - Content
-
... ... @@ -635,6 +635,7 @@ 635 635 (% style="text-align:center" %) 636 636 [[image:1757044137457-543.png||height="468" width="708"]] 637 637 638 + 638 638 == **1.13 JSON encoding and decoding** == 639 639 640 640 This demo shows how to encode tag values into JSON format and decode the JSON to assign data to new tags. ... ... @@ -1921,98 +1921,3 @@ 1921 1921 {{info}} 1922 1922 ✎Note: If you want to use CMD to access Mysql, you need to add the bin file to the environment variable, please check online for details of the operation. 1923 1923 {{/info}} 1924 - 1925 -== **2.8 Google sheet** == 1926 - 1927 - In this demo you can upload the real-time tags data to google sheet 1928 - 1929 -**1.Google sheets setting** 1930 - 1931 -1.1 Create a table file based on actual needs and fill in the headers. 1932 - 1933 -(% style="text-align:center" %) 1934 -[[image:WeCom Screenshot_20260305114836.png]] 1935 - 1936 -1.2 Modify the access permissions of the table to 'Anyone on the internet with the link can edit'. 1937 - 1938 -(% style="text-align:center" %) 1939 -[[image:z6rgXmeOMz1.png]] 1940 - 1941 -1.3 Enable the Apps Script extension feature for the sheet. 1942 - 1943 -(% style="text-align:center" %) 1944 -[[image:u8QbgKcOgA.png]] 1945 - 1946 -1.4 On the Apps Script editing page, program according to actual needs. 1947 - 1948 -Google Apps Script Demo 1949 - 1950 -{{code language="JavaScript"}} 1951 -/** 1952 - * Handles POST requests: parses JSON data, writes it to the sheet with timestamp 1953 - * Expected JSON format: { 1954 - * sheetName: "Sheet1" (optional, defaults to "Sheet1"), 1955 - * integerNumber: 123, 1956 - * floatingNumber: 45.67, 1957 - * stringData: "example text" 1958 - * } 1959 - */ 1960 -function doPost(e) { 1961 - // 1. Parse the JSON data from the request body 1962 - var data; 1963 - try { 1964 - data = JSON.parse(e.postData.contents); 1965 - } catch (error) { 1966 - return ContentService.createTextOutput('Error: Invalid JSON data'); 1967 - } 1968 - 1969 - // 2. Get the target sheet (defaults to "Sheet1") 1970 - var sheetName = data.sheetName || 'Sheet1'; 1971 - var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName); 1972 - if (!sheet) { 1973 - return ContentService.createTextOutput('Error: Specified sheet not found'); 1974 - } 1975 - 1976 - // 3. Verify required fields are present 1977 - if (data.integerNumber === undefined || 1978 - data.floatingNumber === undefined || 1979 - data.stringData === undefined) { 1980 - return ContentService.createTextOutput('Error: Missing required fields (integerNumber, floatingNumber, stringData)'); 1981 - } 1982 - 1983 - // 4. Generate formatted current timestamp (first column) 1984 - var now = new Date(); 1985 - var timeZone = SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTimeZone(); 1986 - var formattedTimestamp = Utilities.formatDate(now, timeZone, "yyyy-MM-dd HH:mm:ss"); 1987 - 1988 - // 5. Extract data from JSON 1989 - var integerNumber = data.integerNumber; 1990 - var floatingNumber = data.floatingNumber; 1991 - var stringData = data.stringData; 1992 - 1993 - // 6. Append the data to the sheet with proper column mapping: 1994 - // Column A: Time (timestamp) 1995 - // Column B: Integer number 1996 - // Column C: Floating number 1997 - // Column D: String data 1998 - sheet.appendRow([formattedTimestamp, integerNumber, floatingNumber, stringData]); 1999 - 2000 - // 7. Return success response 2001 - return ContentService.createTextOutput('Success: Data written to Google Sheets'); 2002 -} 2003 -{{/code}} 2004 - 2005 -(% style="text-align:center" %) 2006 -[[image:PixPin_2026-03-05_14-40-27.png]] 2007 - 2008 -1.5 Click "Deploy" to make a new deployment. Select the 'Web APP' type, set the user permissions, and complete the deployment of the script. 2009 - 2010 -(% style="text-align:center" %) 2011 -[[image:3W00uSwkVQ1.png]] 2012 - 2013 -1.6 In the 'Manage deployments' interface, obtain the URL of the web app. 2014 - 2015 -(% style="text-align:center" %) 2016 -[[image:HoLYu2nzvq.png]] 2017 - 2018 -
- 3W00uSwkVQ1.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.DevinChen - Size
-
... ... @@ -1,1 +1,0 @@ 1 -140.1 KB - Content
- Doa6Qhp4bS.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.DevinChen - Size
-
... ... @@ -1,1 +1,0 @@ 1 -139.2 KB - Content
- HoLYu2nzvq.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.DevinChen - Size
-
... ... @@ -1,1 +1,0 @@ 1 -136.6 KB - Content
- PixPin_2026-03-05_14-40-27.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.DevinChen - Size
-
... ... @@ -1,1 +1,0 @@ 1 -154.8 KB - Content
- WeCom Screenshot_20260305114836.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.DevinChen - Size
-
... ... @@ -1,1 +1,0 @@ 1 -53.5 KB - Content
- u8QbgKcOgA.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.DevinChen - Size
-
... ... @@ -1,1 +1,0 @@ 1 -61.3 KB - Content
- z6rgXmeOMz.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.DevinChen - Size
-
... ... @@ -1,1 +1,0 @@ 1 -80.7 KB - Content
- z6rgXmeOMz1.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.DevinChen - Size
-
... ... @@ -1,1 +1,0 @@ 1 -80.7 KB - Content