Open Office Spreadsheet (Calc) - 使用分隔符连接文本单元格
我正在使用 Open Office 的电子表格程序,并尝试将多个文本单元格与分隔符连接在一起。例如,假设我有下面的单元格:
+--------+
| cell 1 |
+--------+
| cell 2 |
+--------+
| cell 3 |
+--------+
| cell 4 |
+--------+
| cell 5 |
+--------+
我想将它们与分隔符连接起来,以便结果位于像这样的一个单元格中:
+----------------------------------------------+
| (cell 1),(cell 2),(cell 3),(cell 4),(cell 5) |
+----------------------------------------------+
我的第一个想法是尝试制作一个宏或其他东西,但我不认为打开办公室支持这些。有什么想法吗?
I am using Open Office's spreadsheet program and am trying to concatenate several text cells together with delimeters. For example, suppose I have the cells below:
+--------+
| cell 1 |
+--------+
| cell 2 |
+--------+
| cell 3 |
+--------+
| cell 4 |
+--------+
| cell 5 |
+--------+
I would like to concatenate them with delimiters so that the result is in one cell like this one:
+----------------------------------------------+
| (cell 1),(cell 2),(cell 3),(cell 4),(cell 5) |
+----------------------------------------------+
My first thought was to try and make a macro or something, but I don't think open office supports those. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
非常感谢马库斯找到了解决方案。
这里有一些稍微更详细的说明,以帮助像我这样的 OpenOffice Basic 新手。这适用于版本 3.1:
工具 ->宏->组织宏 -> OpenOffice.org Basic...
现在从资源管理器树中选择您想要运行函数的位置,
例如,它可以位于您自己的宏库中(我的宏/标准)或
直接存储在当前电子表格中。
现在输入新的宏名称并单击新建以打开 OO.org Basic IDE。你会看到 REM
语句和一些存根子定义。全部删除并替换
与 Markus 的原始代码相比
上面的代码
当范围中的第一个单元格为空时,不以分隔符开头。
允许可选地选择分隔符(默认为“,”)和
范围内每个非空白条目之前和之后的字符串
(默认为“”)。
我将其重命名为 STRJOIN,因为“join”是它的典型名称
函数在几种流行语言中,例如 Perl、Python 和 Ruby。
变量全部小写
现在保存宏,转到要显示连接的单元格,
并键入:
将 C3:C50 替换为您要连接的字符串范围。
要自定义分隔符,请使用以下内容:
如果您想加入一堆电子邮件地址,您可以使用:
结果将类似于
Thanks a lot Markus for finding a solution to this.
Here are some slightly more detailed instructions for the benefit of OpenOffice Basic newbies like myself. This applies to version 3.1:
Tools -> Macros -> Organize Macros -> OpenOffice.org Basic...
Now select from the explorer tree where you want your function live,
e.g. it can be in your own macro library (My Macros / Standard) or
stored directly in the current spreadsheet.
Now enter a new Macro name and click New to open the OO.org Basic IDE. You'll see a REM
statement and some stub Sub definitions. Delete all that and replace
it with:
The above code has some slight improvements from Markus' original:
Doesn't start with a delimiter when the first cell in the range is empty.
Allows optional choice of the delimiter (defaults to ","), and the
strings which go before and after each non-blank entry in the range
(default to "").
I renamed it STRJOIN since "join" is the typical name of this
function in several popular languages, such as Perl, Python, and Ruby.
Variables all lowercase
Now save the macro, go to the cell where you want the join to appear,
and type:
replacing C3:C50 with the range of strings you want to join.
To customise the delimiter, instead use something like:
If you wanted to join a bunch of email addresses, you could use:
and the result would be something like
好吧,经过大量的搜索和实验,我发现你可以在 calc 中创建自己的函数。这是我制作的一个函数,可以实现我想要的功能:
Well, after a lot more searching and experimenting, I found you can make your own functions in calc. This is a function I made that does what I want:
我经常享受更换和更换的轻松快捷。计算选项以及一般的快速处理和计算选项修改选项,当再次坐在转储文件列表或任何东西前面时。
我真的不明白为什么他们从一开始就不包含如此重要的功能。
它基于 Adam 的脚本,但具有将
CONCAT
从水平交换为垂直的扩展,同时仍保持分隔符的顺序。Ever so often I'd enjoy the ease and quickness of replace & calculation Options as well as in general the quick handling & modifying Options, when once again sitting in front of a dumped-file-lists or whatsoever.
I never understood why they didn't include such an essential function right from the start, really.
It's based on Adam's script, but with the extension to swap
CONCAT
from horizontal to vertical, while still keeping the delimiters in order.