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

查看:189
本文介绍了将编码的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开头,尽管您的开头可能有所不同).这将是一个很长的字符串;甚至一个空文件也将近1万.

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天全站免登陆