找回密码
 立即注册

QQ登录

只需一步,快速开始

洪水永不结冰

论坛元老

23

主题

82

帖子

2万

积分

论坛元老

积分
23029

活字格认证

洪水永不结冰
论坛元老   /  发表于:2014-11-14 14:51  /   查看:7246  /  回复:7
iceman版主您好:
       因为查不到相关帮助文档,想找一个asp.net  实现在线打印、导出excel  、pdf 、word 功能的demo;非常感谢。这些功能都是通过button 调用
补充: 开发环境Vs2012 +spread 7.4

7 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2014-11-14 17:41:00
沙发
回复 1楼洪水永不结冰的帖子

导出 Excel:http://www.gcpowertools.com.cn/L ... ility/Overview.aspx

PDF:
http://www.gcpowertools.com.cn/L ... ToPDF/Overview.aspx

打印:
使用工具条上的打印按钮即可直接打印。
如果希望通过代码打印方法,可以通过前台方法,如下:

  1. <SCRIPT language=javascript>
  2.    function onPrintButtonClick() {
  3.        FpSpread1.Print();
  4.    }
  5. </SCRIPT>
复制代码


目前还无法保存到 Word 文件。

评分

参与人数 1满意度 +5 收起 理由
洪水永不结冰 + 5 非常感谢

查看全部评分

回复 使用道具 举报
洪水永不结冰
论坛元老   /  发表于:2014-11-14 19:18:00
板凳
回复 2楼iceman的帖子

如果我想后台调用打印,打印设置的时候默认为横向打印,我设置属性Orientation 为Portrait,不起作用,请问是什么原因。并去掉http://   ......的下标。 再问如果要在一个单元格行换显示,请问怎么设置;另外打印时需要去掉如下图红色框内的文字,请问怎么去掉,其中左下角的打印的时候会显示http://.....aspx页面
QQ图片20141115113916.jpg (46.48 KB, 下载次数: 266)
回复 使用道具 举报
洪水永不结冰
论坛元老   /  发表于:2014-11-15 15:32:00
地板
回复 2楼iceman的帖子

版主您好,对上面关于打印时需要去掉如下图红色框内的文字,请问怎么去掉,其中左下角的打印的时候会显示http://.....aspx页面我已经找到方法
QQ图片20141115153007.jpg (73.43 KB, 下载次数: 265)
回复 使用道具 举报
洪水永不结冰
论坛元老   /  发表于:2014-11-16 14:00:00
5#
回复 4楼洪水永不结冰的帖子

关于边框的设置我已经找到了 需要设置 BorderWidth=&quot;0px&quot;
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-11-17 11:18:00
6#
回复 3楼洪水永不结冰的帖子

你好,

3# 打印方向问题,您的意思是打印机的默认设置为横向,而需要设置为纵向吗?
Spread目前还无法控件打印方向,提供的内置PrintInfo 类用于设置打印到 PDF效果,测试代码如下:

  1. FarPoint.Web.Spread.PrintInfo prinf = new FarPoint.Web.Spread.PrintInfo();
  2.             prinf.BestFitCols = true;
  3.             prinf.BestFitRows = true;
  4.             prinf.Centering = FarPoint.Web.Spread.Centering.Both;
  5.             prinf.ColEnd = 10;
  6.             prinf.Colors = new System.Drawing.Color[] {
  7.         System.Drawing.Color.Green,
  8.         System.Drawing.Color.Yellow,
  9.         System.Drawing.Color.Gold,
  10.         System.Drawing.Color.Indigo,
  11.         System.Drawing.Color.Brown};
  12.             prinf.ColStart = 0;
  13.             prinf.FirstPageNumber = 1;
  14.             prinf.Footer = &quot;/g\&quot;1\&quot;/cl\&quot;4\&quot;This is Page /p of /pc Pages&quot;;
  15.             prinf.FooterHeight = 40;
  16.             prinf.Header = &quot;/cl\&quot;0\&quot;Print Job For FarPoint Inc./n /n &quot;;
  17.             prinf.HeaderHeight = 40;
  18.             prinf.Margin = new FarPoint.Web.Spread.PrintMargin(10, 10, 10, 10, 20, 20);
  19.             prinf.Opacity = 50;
  20.             prinf.Orientation = FarPoint.Web.Spread.PrintOrientation.Landscape;
  21.             FpSpread1.ActiveSheetView.PrintInfo = prinf;
  22.             FpSpread1.SavePdfToResponse(&quot;test.pdf&quot;);
复制代码

关于 3# 问题红色框问题,目前没有内置属性来控制,需要询问产品组,看是否有合适的解决方案。

如果有其他问题,欢迎继续沟通。

评分

参与人数 1满意度 +5 收起 理由
洪水永不结冰 + 5 非常感谢,关于打印边框的问题,我已经找到 设置borderWidth 可以解决

查看全部评分

回复 使用道具 举报
洪水永不结冰
论坛元老   /  发表于:2014-11-18 11:01:00
7#
回复 6楼iceman的帖子

在用spread在线打印时,怎么代码设置IE去掉页眉页脚.
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-11-18 14:01:00
8#
回复 7楼洪水永不结冰的帖子

你好,

图片中选项为 IE 功能,附件在网页打印页面中的,Spread 无法控制这部分:
untitled.png

Spread 可以控制如图所示部分:

2.png

代码:
  1.         protected override void Render(HtmlTextWriter writer)
  2.         {
  3.             Control vp;
  4.             LiteralControl header;
  5.             LiteralControl footer;

  6.             if (FpSpread1.IsPrint)
  7.             {
  8.                 vp = this.Controls[2].Controls[1].Controls[0];
  9.                 //The Viewport consits of three children
  10.                 //Controls(0) is a LiteralControl and holds the sheet name for text
  11.                 //Controls(1) is a Table and is the downlevel Spread control
  12.                 //Controls(2) is another LiteralControl to force some more line breaks.
  13.                 header = ((LiteralControl)(vp.Controls[0]));
  14.                 header.Text = "<DIV ALIGN=center>页头设置测试</DIV><BR>";
  15.                 footer = ((LiteralControl)(vp.Controls[2]));
  16.                 footer.Text = "<BR><DIV>页脚设置测试</DIV><BR><BR>";
  17.             }
  18.             base.Render(writer);
  19.         }
复制代码


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