Google Apps 宏 - 它们与 Office VBA 宏相比如何?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4348555/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Google Apps macros - how do they compare to Office VBA macros?
提问by notnot
Do any of you use the javascript macro capabilities of Google Apps, particularly for spreadsheets? How do the capabilities compare? Is there anything that Google Apps can't do that can be done with VBA macros?
有没有人使用 Google Apps 的 javascript 宏功能,尤其是电子表格?能力对比如何?有什么 Google Apps 不能做而 VBA 宏可以做的事情吗?
采纳答案by Alain
The VBA in Office has been the same for about 10 years now, still using old VB6. The limitations of that language are endless. No data structures, no logic short-circuiting, limited types, non-object oriented. Google Apps and javascript are presumably on the forefront of technology and so it should not have many of these limitations.
Office 中的 VBA 已经有大约 10 年了,仍然使用旧的 VB6。这种语言的局限性是无穷无尽的。没有数据结构,没有逻辑短路,有限的类型,非面向对象。Google Apps 和 javascript 大概处于技术的最前沿,因此它不应该有许多这些限制。
As for what each is capable of doingthat the other can't, that's a little more difficult to assert. I would argue that both languages are more or less turing complete, so while it may be more or less difficult to do something in each language, in theory, a good enough team of programmers could do just about anything in either.
至于每个人都能够做而另一个人不能做的事情,那就更难断言了。我认为这两种语言或多或少都是图灵完备的,所以虽然用每种语言做某事可能或多或少困难,但理论上,一个足够好的程序员团队可以用任何一种语言做任何事情。
Cheers :D
干杯:D
回答by bruce
I am in the middle of conversion of a complex project from VBA to Google Apps Script as an experiment to see what can be done and what can't.
我正在将一个复杂的项目从 VBA 转换为 Google Apps 脚本,作为实验,看看什么可以做,什么不能做。
In general, the development environment for google apps script is primitive and frustrating. The language is of course javaScript so if you already know that then you have a head start. The problem though is that many of the advantages of javaScript are not realizable since you don't actually have access to DOM elements, and neither do you have an equivalent of Excel shapes - except through the UI object- which is essentially the same as an excel form, with the same kind of events and objects etc.
一般来说,谷歌应用程序脚本的开发环境是原始和令人沮丧的。该语言当然是 javaScript,所以如果您已经知道,那么您就有了一个良好的开端。但问题是,javaScript 的许多优点是无法实现的,因为您实际上无法访问 DOM 元素,而且您也没有与 Excel 形状等效的形状——除了通过 UI 对象——它本质上与excel表格,具有相同类型的事件和对象等。
Another issue is general slowness. You need to be careful how you structure, so that you minimize calls to the spreadsheet data (I got round this by building a values cache), and scalability is very questionable.
另一个问题是普遍缓慢。您需要小心您的结构,以便最大限度地减少对电子表格数据的调用(我通过构建值缓存解决了这个问题),并且可扩展性非常值得怀疑。
I am equally at home with javaScript or VBA, so putting language aside, VBA is currently more fulfilling and quicker to get things done, although there are increasing capabilities built in to apps script to make it extremely promising.
我同样熟悉 javaScript 或 VBA,所以撇开语言不谈,VBA 目前更令人满意,完成工作也更快,尽管应用程序脚本内置了越来越多的功能,使其非常有前途。
I am logging the progress of my migration, and the things I come across and the battles to figure out how to minimize structural change (I am trying to see if I can come up with something that would allow dual maintenance on both platforms), so if you are interested, you can follow along here
我正在记录我的迁移进度,我遇到的事情以及如何最小化结构变化的斗争(我试图看看我是否可以提出一些允许在两个平台上进行双重维护的东西),所以如果你有兴趣,你可以跟随这里
http://ramblings.mcpher.com/Home/excelquirks/gooscript
http://ramblings.mcpher.com/Home/excelquirks/gooscript
Bruce
布鲁斯
回答by Krzysztof Rosinski
I'm trying to create charts in google spreadsheet using google apps script and is seems not possible... It is fairly easy in VBA, maybe vb6 is 10 years old but on the other hand you're able to do everything what you need with your spreadsheet. This is not the case in google scripts though.
我正在尝试使用谷歌应用程序脚本在谷歌电子表格中创建图表,但似乎不可能......在 VBA 中相当容易,也许 vb6 已经有 10 年历史了,但另一方面,你可以做你需要的一切与您的电子表格。但是,在 google 脚本中情况并非如此。
回答by Fink
One of the major hurdles is that Google Apps is web based. Thats were most companies cringe at the thought that you would have your own data not stored securely within your own network. I would never trust Google with that sort of data. I'm sure they have secure data connectors, but why take that risk?
主要障碍之一是 Google Apps 是基于网络的。大多数公司都对自己的数据没有安全存储在自己的网络中的想法感到畏缩。我永远不会相信谷歌会提供那种数据。我确信他们有安全的数据连接器,但为什么要冒这个险呢?
Sure VBA is outdated, and not as sexy as javascript. However, its a great tool for quickly writing small applications, and getting it to the user fast. You only really hear nightmare stories about applications that were built by non-programmers using VBA.
当然 VBA 已经过时了,不像 javascript 那样性感。但是,它是快速编写小型应用程序并快速将其提供给用户的绝佳工具。您只会听到有关由非程序员使用 VBA 构建的应用程序的噩梦故事。
It really depends on your project, and what you want to accomplish. Both have their limitations.
这实际上取决于您的项目以及您想要完成的任务。两者都有其局限性。
回答by Charles Williams
Having taken a quick look at Google Spreadsheet API I get the impression that its currently somewhat limited, for instance:
快速浏览一下 Google Spreadsheet API 后,我的印象是它目前有些受限,例如:
fewer Events, no control of calculation?, no way of writing UDFs?
更少的事件,无法控制计算?,无法编写 UDF?
Has anyone tried using it for serious work?
有没有人尝试将它用于严肃的工作?
回答by Patrick Honorez
By its nature, a Google spreadsheet will not be able to do many things a local program will do. Example: a macro that would import all csv files in a user specified folder and consolidate them.
就其性质而言,Google 电子表格无法完成本地程序可以完成的许多事情。示例:将导入用户指定文件夹中的所有 csv 文件并合并它们的宏。
回答by Chris Spicer
One thing that springs to mind is that VBA has full access to the WinAPI through 'Declare Function' declarations. Google Apps script won't have this access. This is something to watch for if you're converting a spreadsheet between the two.
想到的一件事是 VBA 可以通过“声明函数”声明完全访问 WinAPI。Google Apps 脚本没有此访问权限。如果您要在两者之间转换电子表格,则需要注意这一点。