漂亮的打印 Excel 公式?
有没有办法漂亮地打印Excel公式?
我有一些半复杂公式的工作表需要费力地完成,所以这会让我的生活变得更轻松一些。
我只是想将这样的东西变成
AC6+AD6+(IF(H6="Yes",1,IF(J6="Yes",1,0)))+IF(X6="Yes",1,0)
更具可读性的东西,而无需在 Vim 等中手动执行。 Excel 确实对括号进行了颜色匹配,但它仍然全部混合在一行上。
Is there a way to pretty print Excel formulas?
I've got a few worksheets of semi-complex formulas to slog through, so this would make my life a bit easier.
I'm just looking to turn something like this
AC6+AD6+(IF(H6="Yes",1,IF(J6="Yes",1,0)))+IF(X6="Yes",1,0)
into something more readable without manually doing it in Vim or the like. Excel does do color-matching on the parentheses, but it's still all mashed together on one line.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试使用 Excel 公式美化器 http://excelformulabeautifier.com/。它可以漂亮地打印(又名美化)Excel 公式。
(我帮助维护这一点,总是寻求反馈以使其变得更好。)
Try Excel Formula Beautifier http://excelformulabeautifier.com/. It pretty prints (aka beautifies) Excel formulas.
(I help maintain this, always looking for feedback to make it better.)
此 VBA 代码不会获奖,但可以快速查看典型公式。它只是执行您手动使用括号或分隔符执行的操作。将其粘贴到代码模块中并从 VBA 立即窗口命令行调用它。 (编辑:我最近不得不查看一些公式,并且我对原来答案的内容进行了改进,所以我回来并更改了它。)
如果你这样称呼它:
你不必担心转义你的双引号等等。您将得到如下所示的输出:
您还可以使用纯字符串调用它。
This VBA code will win no awards, but it's O.K. for quickly looking at typical formulas. It just does what you'd do with parens or separators manually. Stick it in a code module and call it from the VBA immediate window command line. (EDIT: I had to look at some formulas recently, and I improved on what was here from my original answer, so I came back and changed it.)
If you call it like so:
you don't have to worry about escaping your double quotes and so on. You'll get output that looks like this:
You can also call it with a plain string.
到 2023 年,迄今为止最简单的方法是安装微软自己的高级公式环境。除了漂亮的打印公式(然后可以将其复制粘贴到常规公式栏中)之外,它还具有许多其他功能。转到“插入”选项卡,“获取加载项”,搜索“Excel Labs”。
我还将衷心推荐“Formula Forge”插件作为评估公式的替代品。它使困难的公式更容易评估。
In 2023, by far the easiest way to do this is to install Microsoft's own Advanced Formula Environment. As well as pretty printing formulas (which can then be copy-pasted into the regular formula bar), it has a host of other features. Go to 'Insert' tab, 'Get Add-ins', search 'Excel Labs'.
I'll also heartily recommend the 'Formula Forge' add-in as a replacement for Evaluate Formula. It makes difficult formulae much, much easier to evaluate.
上述代码片段的这个版本现在也以不同的方式处理引用的字符,这意味着,它不会影响它们,如果它们位于字符串内部,则不会让它们影响缩进,例如:
它由布尔变量 bInsideQuotes 控制。
它还用于
使最终用户能够看到他们知道的东西。
This version of the above code snippet now also handels quoted characters differently, which means, it leaves them alone and doesn't let them effect the indenting if they are inside a string like:
It is controlled by the boolean variable bInsideQuotes.
It also uses
to make it possible for Endusers to see something they know.
我刚刚使用 VS Code sql-formatter 扩展。我只需将公式粘贴到 sql 文件并使用 sql 格式化程序进行格式化。
当我将其归档时,
结果是这样的:
它并不完美,但符合我的口味。并且可以将其复制并重新使用到 Excel / google 表格中。
I just solved the issue by using the VS Code sql-formatter extension. I simply paste my formular to a sql file and format with the sql-formatter.
When I put this to file
It comes out like that:
Its not perfect but acceptable for my taste. And this can be copied and used back into Excel / google sheets.