找回密码
 立即注册

QQ登录

只需一步,快速开始

hyqangel

中级会员

47

主题

152

帖子

939

积分

中级会员

积分
939

活字格认证微信认证勋章

hyqangel
中级会员   /  发表于:2013-6-9 15:34  /   查看:10610  /  回复:13
原来EXCEL文件中有个图,到spread中丢失,而且左上脚多了一个按钮
yyy.png
zzz.png

13 个回复

正序浏览
iceman
社区贡献组   /  发表于:2013-6-24 11:32:00
14#
回复 6楼hyqangel的帖子

hyqangel 你好,
关于直接打印可以通过一下方法自定义实现:

  1.   private void btnPrint_Click(object sender, RoutedEventArgs e)
  2.         {
  3.             this.Cursor = System.Windows.Input.Cursors.Wait;
  4.             SpreadSheetPrinter ssp = new SpreadSheetPrinter(this.gcSpreadSheet1);
  5.             ssp.PrintDocument.EndPrint += (ss, ee) => { this.Cursor = System.Windows.Input.Cursors.Arrow;  };
  6.             ssp.PrintActiveSheet("SpreadSheet Print");
  7.         }

  8.   public class SpreadSheetPrinter
  9.     {
  10.         GcSpreadSheet printSource;
  11.         PrintDocument pd;
  12.         string documentName;
  13.         Grid printVisual;
  14.         Grid container;
  15.         TextBlock header;
  16.         GcSpreadSheet printPreview;
  17.         TextBlock footer;
  18.         int vPageBreak;
  19.         int vNextPageBreak;
  20.         int hPageBreak;
  21.         int hNextPageBreak;
  22.         double pageWidth;
  23.         double pageHeight;
  24.         public SpreadSheetPrinter(GcSpreadSheet spread)
  25.         {
  26.             printSource = spread;
  27.             pd = new PrintDocument();
  28.             pd.PrintPage += new EventHandler<PrintPageEventArgs>(pd_PrintPage);
  29.             this.printVisual = new Grid();
  30.             this.container = new Grid();
  31.             this.container.RowDefinitions.Add(new RowDefinition());
  32.             this.container.RowDefinitions.Add(new RowDefinition());
  33.             this.container.RowDefinitions.Add(new RowDefinition());
  34.             this.printVisual.Children.Add(this.container);
  35.             this.header = new TextBlock();
  36.             this.header.FontSize = 20;
  37.             this.header.VerticalAlignment = System.Windows.VerticalAlignment.Top;
  38.             this.header.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
  39.             this.container.Children.Add(this.header);
  40.             this.footer = new TextBlock();
  41.             this.footer.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
  42.             this.footer.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
  43.             this.container.Children.Add(this.footer);
  44.             this.footer.SetValue(Grid.RowProperty, 2);
  45.             this.printPreview = new GcSpreadSheet();
  46.             this.container.Children.Add(this.printPreview);
  47.             this.printPreview.SetValue(Grid.RowProperty, 1);
  48.             this.printPreview.VerticalAlignment = System.Windows.VerticalAlignment.Top;
  49.             this.printPreview.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
  50.         }
  51.         public PrintDocument PrintDocument
  52.         {
  53.             get { return pd; }
  54.         }
  55.         public void PrintActiveSheet(string documentName)
  56.         {
  57.             MemoryStream ms = new MemoryStream();
  58.             this.printSource.SaveXml(ms);
  59.             ms.Seek(0, System.IO.SeekOrigin.Begin);
  60.             this.printPreview.OpenXml(ms);
  61.             ms.Close();
  62.             // hide scrollbar tabstrip border
  63.             this.printPreview.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
  64.             this.printPreview.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
  65.             this.printPreview.TabStripVisibility = System.Windows.Visibility.Collapsed;
  66.             this.printPreview.BorderThickness = new Thickness(0);
  67.             // hide selection
  68.             var sheet = this.printPreview.ActiveSheet;
  69.             sheet.RowCount++;
  70.             sheet.ColumnCount++;
  71.             sheet.FrozenTrailingColumnCount = 1;
  72.             sheet.FrozenTrailingRowCount = 1;
  73.             sheet.SetRowVisible(sheet.RowCount - 1, SheetArea.Cells, false);
  74.             sheet.SetColumnVisible(sheet.ColumnCount - 1, SheetArea.Cells, false);
  75.             sheet.SetActiveCell(sheet.RowCount - 1, sheet.ColumnCount - 1, true);
  76.             vPageBreak = 0;
  77.             vNextPageBreak = -1;
  78.             hPageBreak = 0;
  79.             hNextPageBreak = -1;
  80.             pageWidth = 0;
  81.             pageHeight = 0;
  82.             this.documentName = documentName;
  83.             pd.Print(documentName);
  84.         }
  85.         void pd_PrintPage(object sender, PrintPageEventArgs e)
  86.         {
  87.             var sheet = this.printPreview.ActiveSheet;
  88.             var margin = sheet.PrintInfo.Margin;
  89.             // set control position
  90.             this.container.Margin = new Thickness(margin.Left, margin.Top, margin.Right, margin.Bottom);
  91.             this.container.RowDefinitions[0].Height = new GridLength(margin.Header);
  92.             this.container.RowDefinitions[2].Height = new GridLength(margin.Footer);
  93.             this.header.Text = this.documentName;
  94.             this.footer.Text = string.Format("page {0}", this.pd.PrintedPageCount + 1);
  95.             // scroll to current page
  96.             this.printPreview.ShowRow(0, vPageBreak, VerticalPosition.Top);
  97.             this.printPreview.ShowColumn(0, hPageBreak, HorizontalPosition.Left);
  98.             // calc current page size, and find next page break
  99.             if (pageHeight == 0) // current page height is not calc yet
  100.             {
  101.                 for (int i = vPageBreak; i < sheet.RowCount; i++)
  102.                 {
  103.                     double rowHeight = sheet.GetActualRowHeight(i, SheetArea.Cells) * sheet.ZoomFactor;
  104.                     if ((pageHeight + rowHeight) > (e.PrintableArea.Height - margin.Bottom - margin.Top - margin.Header - margin.Footer))
  105.                     {
  106.                         vNextPageBreak = i;
  107.                         break;
  108.                     }
  109.                     pageHeight += rowHeight;
  110.                 }
  111.                 if (this.printPreview.Height != pageHeight)
  112.                 {
  113.                     this.printPreview.Height = pageHeight;
  114.                 }
  115.             }
  116.             if (pageWidth == 0) // current page width is not calc yet
  117.             {
  118.                 for (int i = hPageBreak; i < sheet.ColumnCount; i++)
  119.                 {
  120.                     double columnWidth = sheet.GetActualColumnWidth(i, SheetArea.Cells) * sheet.ZoomFactor;
  121.                     if ((pageWidth + columnWidth) > (e.PrintableArea.Width - margin.Left - margin.Right))
  122.                     {
  123.                         hNextPageBreak = i;
  124.                         break;
  125.                     }
  126.                     pageWidth += columnWidth;
  127.                 }
  128.                 if (this.printPreview.Width != pageWidth)
  129.                 {
  130.                     this.printPreview.Width = pageWidth;
  131.                 }
  132.             }
  133.             e.PageVisual = this.printVisual;
  134.             // prepare for next page
  135.             if (sheet.PrintInfo.PageOrder == PrintPageOrder.DownThenOver)
  136.             {
  137.                 if (vNextPageBreak != -1) // has next page in vertical
  138.                 {
  139.                     vPageBreak = vNextPageBreak;
  140.                     vNextPageBreak = -1;
  141.                     pageHeight = 0;
  142.                     e.HasMorePages = true;
  143.                 }
  144.                 else if (hNextPageBreak != -1)
  145.                 {
  146.                     hPageBreak = hNextPageBreak;
  147.                     hNextPageBreak = -1;
  148.                     pageWidth = 0;
  149.                     pageHeight = 0;
  150.                     vPageBreak = 0;
  151.                     vNextPageBreak = -1;
  152.                     e.HasMorePages = true;
  153.                 }
  154.             }
  155.             else
  156.             {
  157.                 if (hNextPageBreak != -1)
  158.                 {
  159.                     hPageBreak = hNextPageBreak;
  160.                     hNextPageBreak = -1;
  161.                     pageWidth = 0;
  162.                     e.HasMorePages = true;
  163.                 }
  164.                 else if (vNextPageBreak != -1)
  165.                 {
  166.                     vPageBreak = vNextPageBreak;
  167.                     vNextPageBreak = -1;
  168.                     pageWidth = 0;
  169.                     pageHeight = 0;
  170.                     hPageBreak = 0;
  171.                     hNextPageBreak = -1;
  172.                     e.HasMorePages = true;
  173.                 }
  174.             }
  175.         }
  176.     }
复制代码
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-6-24 09:36:00
13#
回复 12楼iceman的帖子

hyqangel 你好,

Chart 图表功能将作为 10 月发布版中一大亮点功能发布。
Shape 当前版本不支持,已经列入 wish list 列表中,目前还没有明确的发布计划。

谢谢
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-6-21 18:46:00
12#
回复 10楼hyqangel的帖子

给你带来不便很抱歉,关于你的问题我们会尽快调查找出解决或者替代方法。如果是产品上的不足,我们会向产品组提交。感谢你的反馈。

&quot;带图的电子表格载入系统后,全部消失&quot;
不好意思,这就话的意思是 Cell 中的内容也消失了,还是指图片消失了呢?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-6-21 18:42:00
11#
回复 9楼hyqangel的帖子

hyqangel 你好,

图形指的是否为 Excel 中的 Shape?还是 Chart ?

我在确认之后回复。
回复 使用道具 举报
hyqangel
中级会员   /  发表于:2013-6-21 18:05:00
10#
带图的电子表格载入系统后,全部消失,这也叫兼容EXCEL
回复 使用道具 举报
hyqangel
中级会员   /  发表于:2013-6-21 17:54:00
9#
是不是在SILVERLIGHT 版本中 不支持各种图形功能,例子代码中没有体现,如果这个功能也没有就惨啦
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-6-13 10:42:00
8#
回复 7楼hyqangel的帖子

您好,

感谢您对我们产品的支持。
由于我们产品研发计划是全球统一管理、调配。
目前还没有在十月份添加直接打印到打印机功能的计划。

谢谢
回复 使用道具 举报
hyqangel
中级会员   /  发表于:2013-6-9 22:15:00
7#
和spreadsheetgrear for siverlight对比,他们和excel兼容性似乎更好,
而且支持打印,区域打印,打印设置,之前一直在试用spreadsheetgear,因为考虑技术支持和中文化等因素和促销活动,
仓促购买你们的产品,想当然以为你们都已实现的这些功能,今仔细看了你们demo,
确实没有提及这些功能,我想咨询一下后期你们是不是将重点放到其它平台而非silverlight?
打印之类的问题估计在你们十月份发布版本中能否加上?
回复 使用道具 举报
hyqangel
中级会员   /  发表于:2013-6-9 21:24:00
6#
能不能将打印功能也放到10月份的版本中去呢?这应该是基本功能呀,转成pdf然后打印太麻烦了
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部