找回密码
 立即注册

QQ登录

只需一步,快速开始

moonlight108
初级会员   /  发表于:2013-12-18 14:18:00
11#
回复 10楼iceman的帖子

已经配置了。没用。而且还有好几个奇怪的地方:
1、页面<CommandBar Visible="false"></CommandBar>,但是仍然能看到CommandBar。
2、C#   FpSpread1.UseClipboard = false; 但是点FpSpread,仍然提示“确实允许网页访问剪贴板”
Winform是正常的,如图:

QQ截图20131218144911.png

web就没图了,成这样了:
QQ截图20131218144841.png
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-12-18 17:51:00
12#
回复 11楼moonlight108的帖子

这是我使用的 Spread Win 保存方法,存成一个 XLSX 文件,也可以把文件存成流到数据库中:

  1.         private void saveToolStripMenuItem_Click(object sender, EventArgs e)
  2.         {
  3.             fpSpread1.SaveExcel(stream, FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat);
  4.             stream.Position = 0;
  5.             int leng = stream.Length < Int32.MaxValue ? (int)stream.Length : 0;
  6.             byte[] by = new byte[leng];
  7.             stream.Read(by, 0, leng);
  8.             sContent = Convert.ToBase64String(by);

  9.             Stream localFile = new FileStream("test.xlsx",FileMode.OpenOrCreate);

  10.             localFile.Write(stream.ToArray(), 0, (int)stream.Length);
  11.         }
复制代码


这是 Spread Web 的打开代码,也可以同数据库中提取字节流:

  1.         protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             if (IsPostBack)
  4.             {
  5.                 return;
  6.             }
  7.             string filename = this.Server.MapPath("test.xlsx");
  8.             FileStream fs = new FileStream(filename, FileMode.Open);
  9.             this.FpSpread1.OpenExcel(fs);
  10.         }
复制代码


可以成功的显示波形图,能否把你的 Demo 发上来看看?

1、页面<CommandBar Visible="false"></CommandBar>,但是仍然能看到CommandBar。
2、C#   FpSpread1.UseClipboard = false; 但是点FpSpread,仍然提示“确实允许网页访问剪贴板”
这两个问题,请问你的设置时机是什么?需要在 Open 方法之后设置。
回复 使用道具 举报
moonlight108
初级会员   /  发表于:2013-12-19 10:26:00
13#
回复 12楼iceman的帖子

那两个问题在open 之后设置就对了。谢谢。
Winform下是对的,就不说了。我是把流Base64编码后为字符串保存在数据库中。
下面是Web下的打开代码,其中content是数据库取出的字符串,依然没有波形图只有文字。请帮忙看下问题出在哪。

string filename = this.Server.MapPath(&quot;../temp/test.xlsx&quot;);
            Stream stream = new FileStream(filename, FileMode.OpenOrCreate);
            byte[] buf = Convert.FromBase64String(content);
            stream.Write(buf, 0, buf.Length);
            stream.Close();

            FileStream fs = new FileStream(filename, FileMode.Open);
            this.FpSpread1.OpenExcel(fs);

            FpSpread1.UseClipboard = false;
            FpSpread1.CommandBar.Visible = false;
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2013-12-19 16:05:00
14#
回复 13楼moonlight108的帖子

就上面交流的帖子,汇总一下:
1 Winform Spread和Web Spread之间,无法通用*.xml文件
2 Winform Spread和Web Spread之间,可通过保存为*.xlsx来共享数据

目前的关键是*.xlsx文件需要进入一次DB,步骤如下:
1 Winform Spread  Save *.xlsx文件
2 Winform把*.xlsx转换为byte[]
3 Winform 存储到DB

4 Web加载DB
5 Web转换byte[]为*.xlsx文件
6 Web读取*.xlsx文件

请问你是按照上面的步骤操作的吗?  那一步出了问题?
回复 使用道具 举报
moonlight108
初级会员   /  发表于:2013-12-20 10:20:00
15#
回复 14楼roger.wang的帖子

完全按照这个步骤去做的。
Winform下这样保存:
        string sTempExcel =Application.StartupPath + &quot;\\&quot; + Guid.NewGuid().ToString() + &quot;.xlsx&quot;;
            fpSpread1.SaveExcel(sTempExcel, FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat);
            FileStream stream = new FileStream(sTempExcel, FileMode.Open);
            stream.Position = 0;
            int leng = stream.Length &lt; Int32.MaxValue ? (int)stream.Length : 0;
            byte[] buf = new byte[leng];
            stream.Read(buf, 0, leng);
            string sContent = Convert.ToBase64String(buf);
            stream.Close();
            File.Delete(sTempExcel);

sContent为字节流做base64编码后为字符串保存进数据库。

Web代码为:
string filename = this.Server.MapPath(&quot;../temp/test.xlsx&quot;);
            Stream stream = new FileStream(filename, FileMode.OpenOrCreate);
            byte[] buf = Convert.FromBase64String(content);
            stream.Write(buf, 0, buf.Length);
            stream.Close();
            FileStream fs = new FileStream(filename, FileMode.Open);
            this.FpSpread1.OpenExcel(fs);

有什么问题吗?用xlsx做中介了,还是没有图只有文字。
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2013-12-20 11:01:00
16#
回复 15楼moonlight108的帖子

问题应该处在web Spread打开的工程里面,请使用 4#楼提供的web源码试试

1 Winform Spread:存储为Excel 2007格式,同时,生成*.dat文件(byte[] 文件)

Spread_Win_SaveWinform_SparkLine.rar (54.31 KB, 下载次数: 523)
回复 使用道具 举报
moonlight108
初级会员   /  发表于:2013-12-20 11:28:00
17#
回复 16楼roger.wang的帖子

麻烦问下代码中的mem.CopyTo(localFile); 这个CopyTo如何实现?不是系统方法
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2013-12-20 11:31:00
18#
回复 17楼moonlight108的帖子

CopyTo是:System.IO.Stream的方法。

  1. //
  2.         // Summary:
  3.         //     Reads the bytes from the current stream and writes them to the destination
  4.         //     stream.
  5.         //
  6.         // Parameters:
  7.         //   destination:
  8.         //     The stream that will contain the contents of the current stream.
  9.         //
  10.         // Exceptions:
  11.         //   System.ArgumentNullException:
  12.         //     destination is null.
  13.         //
  14.         //   System.NotSupportedException:
  15.         //     The current stream does not support reading.-or-destination does not support
  16.         //     writing.
  17.         //
  18.         //   System.ObjectDisposedException:
  19.         //     Either the current stream or destination were closed before the System.IO.Stream.CopyTo(System.IO.Stream)
  20.         //     method was called.
  21.         //
  22.         //   System.IO.IOException:
  23.         //     An I/O error occurred.
  24.         public void CopyTo(Stream destination);
复制代码


您说不是系统方法,我没有太理解,能再给补充一下吗?
回复 使用道具 举报
moonlight108
初级会员   /  发表于:2013-12-20 11:56:00
19#
回复 使用道具 举报
moonlight108
初级会员   /  发表于:2013-12-20 12:06:00
20#
System.IO.Stream以C开头的方法和属性只有下面红框里的几个,没有CopyTo方法。

未命名.GIF
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部