找回密码
 立即注册

QQ登录

只需一步,快速开始

figoyu
金牌服务用户   /  发表于:2015-10-20 08:59  /   查看:10314  /  回复:5
如题

5 个回复

倒序浏览
frank.zhang
社区贡献组   /  发表于:2015-10-20 10:31:00
沙发
您好,

这个问题可以分为以下几种情况:
1,如果您使用addPicture的方式,并且使用base64的格式,是可以导出到excel的。
2,如果您使用addPicture的方式,使用URL的格式,只能将URL导出到excel。我们的产品,不会修改用户设置的数据。
3,如果您使用的是backgroundImage,excel本身不支持backgroundImage,所以这个信息就会丢失。

如果您希望所有的图片都导出到excel,可以将URL转换为base64的方式。
回复 使用道具 举报
figoyu
金牌服务用户   /  发表于:2015-10-26 22:19:00
板凳
回复 2楼frank.zhang的帖子

按照你的方法,把URL转换为base64编码,还是不能导出图片,导出代码是按照文档上写的。
1、导出代码
  1. var spread = self.spread;
  2.         var utils = new SpreadJsUtils();
  3.         self.ClearProtectSpread();

  4.         var serverUrl = "http://localhost:9000/xsapi/export";
  5.         var optContentType = "application/json";
  6.         console.log(spread.toJSON());
  7.         var dataObj = {
  8.             "spread": spread.toJSON(),
  9.             "exportFileType": "xlsx, xls",
  10.             "excel": {
  11.                 "saveFlags": "NoFlagsSet",
  12.                 "password": ""
  13.             },
  14.             "exportFileName": wtm_global.tmName
  15.         };

  16.         var content = JSON2.stringify(dataObj);
  17.         var formInnerHtml = '<input type="hidden" name="type" value="' + utils.HtmlSpecialCharsEntityEncode(optContentType)
  18.             + '" />';
  19.         formInnerHtml += '<input type="hidden" name="data" value="' + utils.HtmlSpecialCharsEntityEncode(content) + '" />';
  20.         var $iframe = $("<iframe style='display: none' src='about:blank'></iframe>").appendTo("body");

  21.         $iframe.ready(function () {
  22.             var formDoc = utils.GetIframeDocument($iframe);
  23.             formDoc.write("<html><head></head><body><form method='Post' action='" + serverUrl + "'>"
  24.                 + formInnerHtml + "</form>dummy windows for postback</body></html>");
  25.             var $form = $(formDoc).find('form');
  26.             $form.submit();
  27.         });
复制代码


2、spread.toJSON()返回的json对象如下,可以看到图片的src是base64编码。

QQ截图20151026221430.png
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-10-27 10:51:00
地板
您好,

这个问题可能是一个BUG,需要您上传一个能够重现这个问题的例子程序,我们需要对这个问题进行进一步的确认。

我自己做了一个示例,但是没有能够重现这个问题。

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>SpreadJS Pluggable Sample</title>
  5.     <link href="gcspread.sheets.8.40.20151.5.css" rel="stylesheet" type="text/css" />
  6.     <script src="jquery-1.8.2.min.js" type="text/javascript"></script>
  7.     <script type="text/javascript" src="gcspread.sheets.all.8.40.20151.5.min.js"></script>
  8.     <script type="text/javascript">
  9.         $(document).ready(function ()
  10.         {
  11.             var spread = new GcSpread.Sheets.Spread($("#ss").get(0), {
  12.                 sheetCount: 3
  13.             });
  14.             var sheet = spread.getActiveSheet();

  15.             var base64Image =
  16. "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAKTWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVN3WJP3Fj7f92UPVkLY8LGXbIEAIiOsCMgQWaIQkgBhhBASQMWFiApWFBURnEhVxILVCkidiOKgKLhnQYqIWotVXDjuH9yntX167+3t+9f7vOec5/zOec8PgBESJpHmomoAOVKFPDrYH49PSMTJvYACFUjgBCAQ5svCZwXFAADwA3l4fnSwP/wBr28AAgBw1S4kEsfh/4O6UCZXACCRAOAiEucLAZBSAMguVMgUAMgYALBTs2QKAJQAAGx5fEIiAKoNAOz0ST4FANipk9wXANiiHKkIAI0BAJkoRyQCQLsAYFWBUiwCwMIAoKxAIi4EwK4BgFm2MkcCgL0FAHaOWJAPQGAAgJlCLMwAIDgCAEMeE80DIEwDoDDSv+CpX3CFuEgBAMDLlc2XS9IzFLiV0Bp38vDg4iHiwmyxQmEXKRBmCeQinJebIxNI5wNMzgwAABr50cH+OD+Q5+bk4eZ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/ta9mqfiqv1kuRQePjk68pkj4FSfX66HRA8ujfDPapvveWN4n1xKAC5H9CB3SRo767m9uhvRxQUGXAEXOt3uCodViWpT4Yi+tC1Rrhj99/luV8QQ43unrkxWaNVSqvXSNgHSeQSqU2A4Zt2xUdHR3bp6amwp8uTNU91jRgij2PAWg1da+sTwmeGTv768TExN8jIyOk0xlOnTpNMpkiFovR3t6O67rcuPHDJkCtr6U7zVH/gffPKrwravLzC75EIkGxWOTWrVWKxR+Zn79EPB7HdV3m5uYaAK12/xfmxm0P1uwW62D36p77nzdXVr4Txwn5h4aGVkqlEp6XJ5PJ4LouMzMzDYAGiPXkGwGJLGIAyqmPYod6sEM9vziRF0xALMvS0+n0zdnZWTo7O5mcnNwHaNevi27bqN0v+w1pWyj5AOUEjygn1I3VeLzaund/xfj4uAASi8WWM5kMLS0tAAYgV69+K5cvvyq/zZ7TpG1hzZaqbZbsDR3DPnSi2n6ka0uhUJB8Pt+QSCTo7++nqamJ204YXV1PG5aF2nFxUgn7PlGAWIefVXYoihVufcBWorLZrOTz+YMDAwN/tba2UlZWRi6Xq7itmQbb9JnU25qMvvmRAKrmoafEqY/edOqf2bljV/iebDYrgPT29q6Ew2FM06RQKFQMDw+L4ziabaP3nXwpIBy9oACVnBblHOh52N4Vqaxr7jYAFQwGty4uLm72PE/3PK8yt+QZuawnjgSN0TOiDj36nCmP9364pjiY1hJ67RX8F5dMBUjtW7Xav+Xh3PRnIiK6CF/qd/66886YHvW3Sfh8lQHfy11Z2MCegBgioknbCZQTPr1l71di/IcUqjsgLfHzvn8GACNDKumTxWELAAAAAElFTkSuQmCC";
  17.             var cellImage = base64Image;
  18.             sheet.getCell(1, 1).backgroundImage(cellImage);
  19.             sheet.addPicture("f2", base64Image, 2, 2, 6, 6);

  20.         });
  21.     </script>
  22. </head>
  23. <body>
  24.     <div id="ss" style="width: 600px; height: 400px; border: 1px solid gray">
  25.     </div>
  26. </body>
  27. </html>
复制代码
回复 使用道具 举报
figoyu
金牌服务用户   /  发表于:2015-10-27 11:09:00
5#
回复 4楼frank.zhang的帖子

发现问题了,应该是excel文档格式的问题,如果上传的是xlsx格式的,导出后也应该是xlsx,图片才能导出
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-10-27 12:24:00
6#
您好,问题已经解决,本帖关闭,如有其它问题,请开新帖。


为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部