如何将 Excel 表格转换为 Trac Wiki 表格式?

发布于 2024-09-26 13:54:44 字数 188 浏览 10 评论 0原文

我看过复制品和将转换器粘贴为 MediaWiki 或 HTML 格式。但我找不到一种可以转换为 Trac Wiki 格式 (WikiFormattting) 的格式,该格式使用管道来分隔单元格,例如:

||Cell 1||Cell 2||Cell 3|| 
||Cell 4||Cell 5||Cell 6||

I've seen copy & paste converters to MediaWiki or HTML format. But I could not find one that converts to the Trac Wiki format (WikiFormattting) which uses pipes to separate cells, such as:

||Cell 1||Cell 2||Cell 3|| 
||Cell 4||Cell 5||Cell 6||

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

走野 2024-10-03 13:54:44

您可以将 Excel 工作表另存为 CSV 文件。然后从命令提示符(假设您运行的是 Windows XP 或更高版本)键入以下命令:

for /f "tokens=1,2,3 delims=," %a in (mycsvfile.csv) do ((echo ^|^|%a^|^|%b^|^|%c^|^|) >> mywikifile.txt)

令牌的数量取决于您拥有的列数。通过增加标记数量并添加相应数量的变量名称 %d、%e 等,您可以在一次传递中最多执行 26 列。

You could save your excel sheet as a CSV file. Then from a command prompt (assuming you are running Windows XP or newer) type this command:

for /f "tokens=1,2,3 delims=," %a in (mycsvfile.csv) do ((echo ^|^|%a^|^|%b^|^|%c^|^|) >> mywikifile.txt)

The number of tokens depends on how many columns you have. You could do up to 26 columns this way in a single pass by increasing the number of tokens and adding the corresponding number of variable names %d, %e, etc.

梦罢 2024-10-03 13:54:44

我制作了一个 jsFiddle 来执行此操作,只需将您的 CSV 测试放入 HTML框并运行脚本。您要粘贴到 TracWiki 页面的内容将位于 Result 框中。

如果 jsFiddle 发生问题,这里是我使用的 JavaScript(我可能不需要使用 jQuery,但对我来说,必须考虑非 jQuery 方法来做到这一点更快:

var csv = $('body').html().trim();
csv = csv.replace(/,/g, "||");
csv = csv.replace(/$/gm, "||<br />");
csv = csv.replace(/^/gm, "||");
// set to false if you don't want empty cells
if (true) {
    while (csv.indexOf("||||") > -1) {
        csv = csv.replace(/\|\|\|\|/g, "|| ||");
    }
}
$('body').html(csv);

I made a jsFiddle to do just this, just put your CSV test in the HTML box and run the script. The content that you would paste into a TracWiki page would be in the Result box then.

In case something happens to the jsFiddle, here is the JavaScript I used (I probably didn't need to use jQuery, but it was faster for me then to have to think of the non-jQuery way to do it:

var csv = $('body').html().trim();
csv = csv.replace(/,/g, "||");
csv = csv.replace(/$/gm, "||<br />");
csv = csv.replace(/^/gm, "||");
// set to false if you don't want empty cells
if (true) {
    while (csv.indexOf("||||") > -1) {
        csv = csv.replace(/\|\|\|\|/g, "|| ||");
    }
}
$('body').html(csv);
め七分饶幸 2024-10-03 13:54:44

我的 Shan Carter 先生数据转换器端口现在支持您指定的格式的 Wiki。您可以复制并直接从 Excel 或 CSV 文件粘贴。

http://thdoan.github.io/mr-data-converter/

更新:我在“Trac”选项下添加了 Trac 特定的格式。

My port of Shan Carter's Mr. Data Converter now supports Wiki in the format you specified. You can copy & paste directly from Excel or from a CSV file.

http://thdoan.github.io/mr-data-converter/

UPDATE: I've added Trac-specific formatting under the "Trac" option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文