Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
LemonWiki共筆
Search
Search
Appearance
Log in
Personal tools
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Convert number to chinese words
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Convert number to Chinese words in Google sheet == Source of formula: PTT<ref>[https://www.ptt.cc/bbs/Office/M.1644921987.A.FA8.html Re: (問題) google sheet 數字轉中文大寫 - 看板 Office - 批踢踢實業坊]</ref> <pre> =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(A1,"0億0仟0佰0拾0萬0仟0佰0拾0元"),"1","壹"),"2","貳"),"3","參"),"4","肆"),"5","伍"),"6","陸"),"7","柒"),"8","捌"),"9","玖"),"0","零") </pre> Apps script version <pre> function NUMBER2HANS(input) { let numbers = '0123456789' let hans = '零壹貳參肆伍陸柒捌玖' const hans_digits = ['元', '拾', '佰', '仟', '萬', '拾萬', '佰萬', '仟萬', '億'] //input = input.trim() //input = input.replace(/^\s+|\s+$/gm,''); let length = input.length; //console.log("length: " + length); // javascript - How can I pad a value with leading zeros? - Stack Overflow https://stackoverflow.com/questions/1267283/how-can-i-pad-a-value-with-leading-zeros maxLength = 9; // maxLength is the max string length, not max # of fills input = input.toString().padStart(maxLength, "0"); length = input.length; let output = '' for (let i = 0; i < input.length; i++) { let currentDigit = length - i - 1; //console.log("currentDigit: " + currentDigit); let currentHansDigit = hans_digits[currentDigit]; //console.log("currentHansDigit: " + currentHansDigit); let currentChar = input.charAt(i) //console.log("currentChar: " + currentChar); let currentHans = hans.charAt(currentChar) //console.log("currentHans: " + currentHans); //let output = currentHans + currentHansDigit output += currentHans + currentHansDigit //console.log("output: " + output); } return output } </pre>
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki共筆:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)