简体   繁体   English

如何让字体大小显示在 Google 表格的单元格中

[英]How to get font size to show up in a cell in Google Sheets

i've been looking everywhere for solution.我一直在到处寻找解决方案。

I want to create an app script on Google Sheets that creates a custom formula to show what font size text a cell contains.我想在 Google 表格上创建一个应用脚本,该脚本创建一个自定义公式来显示单元格包含的字体大小文本。

I found Google has a function " getFontSize ", but no luck in getting it to work:我发现谷歌有一个 function “ getFontSize ”,但没有让它工作:

 function FONTSIZE(range) { return getFontSize(Number) }

Any help would be appreciated as i am a script app noob!任何帮助将不胜感激,因为我是一个脚本应用程序新手!

I believe your goal is as follows.我相信你的目标如下。

  • You want to retrieve the font size.您要检索字体大小。
  • From your showing script, you might want to achieve this as a custom function.从您的显示脚本中,您可能希望将其作为自定义 function 来实现。

In this case, how about the following modification?在这种情况下,如何进行以下修改?

Modified script:修改后的脚本:

function FONTSIZE(range) {
  return SpreadsheetApp.getActiveSheet().getRange(range).getFontSizes();
}
  • In this case, please put a custom function like =FONTSIZE("A1") and =FONTSIZE("A1:C3") in a cell.在这种情况下,请将自定义 function 像=FONTSIZE("A1")=FONTSIZE("A1:C3")放入单元格中。 By this, the font size of the cell "A1" is returned.这样,就返回了单元格“A1”的字体大小。

Note:笔记:

  • When I saw your showing document of the URL, it seems that it is for Google Slides.当我看到您的 URL 的展示文档时,它似乎是用于 Google 幻灯片的。 If you want to use this with Google Spreadsheet, please use getFontSize() and/or getFontSizes() .如果您想将此与 Google 电子表格一起使用,请使用getFontSize()和/或getFontSizes()

References:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM