有没有办法在 Google 表格中点击鼠标放大图像?

Is there a way to enlarge an image on mouse click in Google Sheets?

我基本上在 table 中有一些小图片,我想通过单击鼠标将其放大。我希望放大的图像出现在页面的中央。再次单击鼠标可删除放大的图像。我能够使用我发现的 VB 脚本在 Excel 上执行此操作,但在 Google 表格中没有运气。有没有办法将这种脚本分配给每个图像?

与此类似http://imgur.com/ETyflIS

亲切的问候,

亚历克斯

您可以将脚本分配给图像,但脚本无法(我可以看到)确定正在单击哪个图像。脚本也可以插入一个新图像,但是这个图像没有分配给它的脚本,所以我们不能让它在点击时消失。

我想您可以分配一个脚本,使用 HTML 服务打开图像,如下所示:

Enlarge Picture on Click

但是您需要为每个图像创建一个单独的函数,以便它可以将源加载到 HTML,或者识别以某种方式单击了哪个图像(我会考虑但我不知道'认为这可以做到。

编辑: 下面的脚本。第一张图片应该 运行 popUp1,第二张图片应该 运行 popUp2。可能有一个更优雅的解决方案来为 HTML 提供不同的图像 URL 但这可行。

code.gs

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('Actions')
  .addItem('Authorise', 'Auth')
  .addToUi();
}

function Auth() {
  SpreadsheetApp.getActiveSpreadsheet();
}


function popUp1() {
  var html = HtmlService.createHtmlOutputFromFile('index1')
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
  html.setHeight(400);
  html.setWidth(600);
  SpreadsheetApp.getUi()
      .showModalDialog(html, 'Image');
}

function popUp2() {
  var html = HtmlService.createHtmlOutputFromFile('index2')
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
  html.setHeight(400);
  html.setWidth(600);
  SpreadsheetApp.getUi()
      .showModalDialog(html, 'Image');
}

index1.html

<form>
  <div id="closeDiv"><font face="arial" size="1">Click the image to close...</font></div>
  <img src="http://www.hdwallpapersimages.com/wp-content/uploads/2014/01/Winter-Tiger-Wild-Cat-Images-540x303.jpg" alt="DJ BBQ" style="width:540px;height:303px;" onClick="closeImage()">
</form>

<script type="text/javascript">
  function closeImage() {
    google.script.host.close();
  }
</script>

index2.html

<form>
  <div id="closeDiv"><font face="arial" size="1">Click the image to close...</font></div>
  <img src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" alt="DJ BBQ" style="width:540px;height:303px;" onClick="closeImage()">
</form>

<script type="text/javascript">
  function closeImage() {
    google.script.host.close();
  }
</script>

你可以 google chrome add-on: Docs Image Zoomer

在这里测试:Example

不确定这是否是您正在寻找的,也不确定您是否找到了其他解决方案,但是如果您转到 insert/drawing,您可以将您的全尺寸图像粘贴到那里,插入它,然后在细胞。 如果双击图像,将弹出全尺寸绘图。 但是,这仅适用于编辑器。不是观众也不是评论者。 此外,您必须单击“保存并关闭”才能返回。 ESC 或单击外部都不会关闭绘图编辑器。

示例:https://docs.google.com/spreadsheets/d/1KDcRQngFy1zRUrD6v2FYH-YPBivZGiUlSKt_PhjeZqU/edit#gid=0

希望对您有所帮助。

恩里克