将 Base64 编码转换为 XSLX [英] Conversion of Base64 Encoded into XSLX

查看:61
本文介绍了将 Base64 编码转换为 XSLX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看我的邮件服务器的文本版本;看到文件名= xyz.xslx & 的附件Content-Transfer-Encoding: base-64 之后是 Base64 编码的代码流.最初的内容类型是 Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;

I was looking into my Mail Server in Text version; There is saw an attachment of filename= xyz.xslx & Content-Transfer-Encoding: base-64 and after that there was stream of Base64 encoded Code. Initially the content-type was Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;

现在,是否可以转换 base-64 编码的字符串代码来检索 xslx 文档?我尝试使用几个在线网站,如 base64decode.org,但由于初始文件类型是 xslx,它也没有以纯文本形式提供任何输出.那么我该如何解决问题呢?

Now, Is it possible to convert the base-64 encoded string code to retrieve the xslx document? I tried using several online sites like base64decode.org but as the initial file type was xslx, it didn't gave any output in Plain-Text too. So how do i work out with issue ?

推荐答案

尝试使用下面的代码片段将 base64 字符串下载为 xlsx 文件.

Try using the snippet below to download your base64 string as an xlsx file.

继续阅读以获取说明.`

Read on for instructions. `

function saveAsXlsxFile(){
  var pre="data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,";
  var inp = document.getElementById('base64input');
  var anchor = document.getElementById('stuff');
  anchor.href=pre+inp.value;
  anchor.style.display="block";
}

<a id="stuff" href="" style="display:none" >Click here to download as an xlsx file</a>
<input placeholder="paste the base64 data here, exclude readable headers" id='base64input' type="text"><br>
<input onclick="saveAsXlsxFile()" type="button" value="update content of link"></button>

`我制作了一个 XLSX 文件,并使用 JavaScript 将其导入浏览器.开头是这样的:

` I made an XLSX file, imported it into the browser with JavaScript. It starts like this:

"data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,UEsDBBQABgAIA

我们希望忽略任何看起来像开头部分的内容(可读的内容),只复制 base64 数据字符串(在我的示例中以 UEsDBBQABgAIA 开头的部分,尽管您的开头可能不同).这将是一个很长的字符串;即使是一个空文件也差不多 10k.

We want to ignore anything that looks like the beginning part (the readable stuff) and only copy the base64 data string (the part beginning with UEsDBBQABgAIA in my example, though yours may start with something different). It's going to be a very long string; even an empty file is almost 10k.

复制那个大而长的 base64 数据字符串(不包括类似于上面非粗体部分的任何标题)并将其粘贴到代码段的输入字段中.

Copy that big long base64 data string (exclusive of any headers similar to the non-bold part from above) and paste it into the input field in the snippet.

您应该获得一个链接,可以将其下载为 xlsx 文件.

You should get a link that lets you download it as an xlsx file.

如果您得到一个乱码文件,请确保您没有意外粘贴在换行中插入了换行符的输入,并记住 base64 字符串的最后几个字符可能是 = 并且包含每个字符很重要.

If you get a garbled file, make sure you didn't accidentally paste input that had newlines inserted from line wrapping, and keep in mind that the last few chars of the base64 string could be characters like = and it's important to include every character.

试一试,告诉我进展如何.

Give it a shot and let me know how it goes.

这篇关于将 Base64 编码转换为 XSLX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆