php 纯文本输出与 google 表格的兼容性

发布于 2025-01-13 14:59:25 字数 1160 浏览 4 评论 0原文

我用 PHP 编写了一个脚本,以适应我在 google 表格中制作的模板。为了方便起见,我制作了输出文本:

header("content-type: text/plain");

当我要使用 =IMAGE 或其他内容时,我不需要 html。现在,我正在尝试制作它,这样我就可以无脑地将浏览器的输出复制并粘贴到谷歌表格中。 “\t”对于换行符来说工作得很好,但是“\t”有一些问题,谷歌表格认为选项卡中的每个空格都是实际的空格,所以它给出了#ERROR!当我尝试一次执行多个选项卡时。

错误: https://puu.sh/IOp2B/34b7f5ce50.png

这是我的代码:

$tab = "\t";
echo '=IMAGE("https://www.smogon.com/forums//media/minisprites/' . strtolower($final)     . '.png")' . htmlspecialchars($tab) . $key . htmlspecialchars($tab) . substr(strval(($value/count($allteams) * 100)), 0, 5) . '%' . $tab . $value . "\n";

我尝试了“\t”本身,没有 htmlspecialcharacters,但直接从网页复制始终使其成为多个空格而不是制表符。我也尝试过使用不同的浏览器。

这是我的问题:

  1. 是否有一个功能可以使选项卡复制为选项卡而不是现在的功能?
  2. 我可以做一个谷歌表格来让另一个字符(不是制表符)分割列吗?如果是这样,我将用分号或其他东西替换代码中的选项卡,我尝试了 data ->拆分列,但仅在粘贴数据时不适用于空白模板。我想让数据完美粘贴,而不需要用户摆弄。

我不认为这是浏览器的问题,我尝试了 3 个不同的浏览器,但问题仍然存在。另外,如果我将输出放入pastebin/文本编辑器中,它之后效果很好,但我不希望用户必须这样做。

我要研究 importxml,但我还没有关于它的信息...只是想我会问

tldr 我的纯文本输出 html 代码很棒,但它不能很好地为我的 google 工作表模板分隔列。

I made a script in PHP to fit into a template I made in google sheets. I made the output text for convenience:

header("content-type: text/plain");

I didn't need html when I'm going for the =IMAGE or whatever. Now, I'm trying to make it so I can brainlessly copy and paste the output from my browser to the google sheets. "\t" worked completely fine for newlines, but "\t" is having some issues where google sheets thinks every single space in the tab is an actual space, so it gives an #ERROR! when i try to do multiple tabs at once.

the error: https://puu.sh/IOp2B/34b7f5ce50.png

here's my code:

$tab = "\t";
echo '=IMAGE("https://www.smogon.com/forums//media/minisprites/' . strtolower($final)     . '.png")' . htmlspecialchars($tab) . $key . htmlspecialchars($tab) . substr(strval(($value/count($allteams) * 100)), 0, 5) . '%' . $tab . $value . "\n";

I tried "\t" itself, no htmlspecialcharacters, but copying directly from the webpage is consistently making it multiple spaces instead of a tab. I also tried with different browsers.

Here are my questions:

  1. Is there a function to make the tabs copy as tabs instead of what it does now?
  2. Is there a google sheets thing I can do to make another character (not tab) split up the columns? If so, I will replace the tab in my code with a semicolon or something, I tried data -> split columns but it doesn't work for a blank template, only when data is pasted. I want to make the data paste perfectly with no fiddling from the user.

I don't think is a browser thing, I tried like 3 different ones and the issue persists. Also, if I put the output into pastebin/text editor, it works well after, but I don't want the user to HAVE to do this.

I am going to look into importxml, but I have no info on it yet... just thought I'd ask

tldr my plaintext output html code has been great but its not separating columns well for my google sheet template.

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

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

发布评论

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

评论(1

客…行舟 2025-01-20 14:59:25

不要使用制表符或 \t,而是按如下方式编写公式,

echo '={image("https://i.sstatic.net/5iCFq.png"),"other info","next info"}'

使用 , (或 ; 根据您的语言环境)分隔不同的单元格和大括号 { }

像往常一样在 php 中使用 .$ 包含特定信息

Instead of using tab or \t, write your formula as follows

echo '={image("https://i.sstatic.net/5iCFq.png"),"other info","next info"}'

use , (or ; according to your locale) to separate the different cells and curly brackets { }

include specific information as usual in php with . and $

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