.setText with % rounded to 1 decimal place

Skip to first unread message

Amanda Kichline

Sep 27, 2022, 6:41:07 PM9/27/22
to Google Apps Script Community
I am working on a script that pushes data from a table in Google Sheets into a table in Google Docs. I've created variables for the data I am pulling from the table in Google Sheets. The data is displayed as a % in the table in Google Sheets (e.g. 70%) but is pushing into the Google Doc as a number (e.g. 0.8). 

I'd like to push the data into the Google Doc as a % rounded to 1 decimal place. See below for code where I'm pulling the variables into the Google Doc table using .setText(variable)

let table2 = body.getTables()[1];


Keith Andersen

Sep 27, 2022, 9:47:31 PM9/27/22
to google-apps-sc...@googlegroups.com
Why not create a pivot table, then copy it and paste into the doc...it will as you if you want to link it. Choose yes. Then every time you update the pivot table on the spreadsheet it will update in the document.

Charlie Health
https://www.instagram.com/gocharliehealth/ https://www.facebook.com/gocharliehealth https://www.linkedin.com/company/66938931/admin/ https://twitter.com/charliehealth

CONFIDENTIALITY NOTICE: This email message, including any attachments, is protected under the Federal regulations governing Confidentiality by the Accountability Act of 1996 ("HIPAA"), 45 C.F.R. The Federal rules prohibit any further disclosure of this information unless a written consent is obtained from the person to whom it pertains. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
Please note: Email is not a secure form of communication and confidentiality cannot be guaranteed. Further, we cannot guarantee that email messages will be read within a given period of time. If you wish to speak with a counselor, call Charlie Health at (406) 361-3001 between 8 a.m. and 5 p.m. Mon.-Fri. Crisis counseling is available by calling 1-800-273-TALK. If your needs are urgent, call 911 or go to the nearest hospital emergency room. 

You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/d64b4ddf-c5bb-4785-b02c-a77ce748db8dn%40googlegroups.com.

Andrew Roberts

Sep 28, 2022, 5:22:31 AM9/28/22
to google-apps-sc...@googlegroups.com

Amanda Kichline

Sep 28, 2022, 9:44:11 AM9/28/22
to Google Apps Script Community
Because I'm creating 150+ documents. I'm also auto generating PDFs and emailing them out. So I don't want to do a pivot table 

Laurie J. Nason

Sep 29, 2022, 12:30:34 AM9/29/22
to google-apps-sc...@googlegroups.com
Hi Ananda, 
I would re-iterate what I think someone also suggested earlier - in your google sheet, get the sheet showing what you want to put in the document and when you retrieve the data from it, instead of using getValue(), use getDisplayValue() instead.

------ Original Message ------
From "Amanda Kichline" <amanda....@charliehealth.com>
To "Google Apps Script Community" <google-apps-sc...@googlegroups.com>
Date 28/09/2022 16:44:11
Subject Re: [Apps-Script] .setText with % rounded to 1 decimal place

Reply all
Reply to author
0 new messages