请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

xzhy80

注册会员

5

主题

27

帖子

56

积分

注册会员

积分
56

活字格认证微信认证勋章

xzhy80
注册会员   /  发表于:2016-7-29 15:57  /   查看:5060  /  回复:6
日本grapecity网站的内容http://www.grapecity.com/tools/support/technical/knowledge_detail.asp?id=38838
クリップボードのデータからペースト先のセル範囲を取得する方法文書番号 : 38841     文書種別 : HowTo
登録日 : 2015/06/25     最終更新日 : 2015/06/25



対象製品SPREAD for Windows Forms 8.0J
詳細シート上でのペースト(Ctrl+V)時にはClipboardPastingイベントが発生するので、同イベントにおいて、以下のようにクリップボード内のデータからペースト対象となるセル範囲を取得することが可能です。

◎サンプルコード(VB)
Private Sub FpSpread1_ClipboardPasting(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.ClipboardPastingEventArgs) Handles FpSpread1.ClipboardPasting
  ' クリップボード内のデータ取得
  Dim data As FarPoint.Win.Spread.CellInfoRange = Clipboard.GetData("FarPoint.Win.Spread.CellInfoRange")
  Dim row1 As Integer = FpSpread1.ActiveSheet.ActiveRowIndex
  Dim col1 As Integer = FpSpread1.ActiveSheet.ActiveColumnIndex

  MessageBox.Show("ペースト開始行インデックス:" & row1 & System.Environment.NewLine & _
          "ペースト開始列インデックス:" & col1 & System.Environment.NewLine & _
          "ペースト行数:" & data.RowCount & System.Environment.NewLine & _
          "ペースト列数:" & data.ColumnCount)
End Sub



◎サンプルコード(C#)
private void FpSpread1_ClipboardPasting(object sender, FarPoint.Win.Spread.ClipboardPastingEventArgs e)
{
  // クリップボード内のデータ取得
  FarPoint.Win.Spread.CellInfoRange data = (FarPoint.Win.Spread.CellInfoRange)Clipboard.GetData("FarPoint.Win.Spread.CellInfoRange");
  int row1 = FpSpread1.ActiveSheet.ActiveRowIndex;
  int col1 = FpSpread1.ActiveSheet.ActiveColumnIndex;

  MessageBox.Show("ペースト開始行インデックス:" + row1 + System.Environment.NewLine +
          "ペースト開始列インデックス:" + col1 + System.Environment.NewLine +
          "ペースト行数:" + data.RowCount + System.Environment.NewLine +
          "ペースト列数:" + data.ColumnCount);
}




6 个回复

倒序浏览
xzhy80
注册会员   /  发表于:2016-7-29 15:59:59
沙发
http://www.grapecity.com/tools/support/technical/knowledge_detail.asp?id=38842

ヘッダ部のコピーだけ有効にし、ヘッダ部への文字の貼り付けを無効にする方法文書番号 : 38842     文書種別 : HowTo
登録日 : 2015/06/25     最終更新日 : 2015/06/25



対象製品SPREAD for Windows Forms 8.0J
詳細シート上でクリップボードの値が変更された時にはClipboardChangingイベント、ペースト(Ctrl+V)時にはClipboardPastingイベントがそれぞれ発生するため、これらのイベント内でClipboardOptionsの設定を変更することで、ヘッダのコピーを可能にし、ヘッダへの貼り付けを禁止することができます。

◎サンプルコード(VB)
Private Sub FpSpread1_ClipboardChanging(ByVal sender As Object, ByVal e As System.EventArgs) Handles FpSpread1.ClipboardChanging
  FpSpread1.ClipboardOptions = FarPoint.Win.Spread.ClipboardOptions.AllHeaders
End Sub

Private Sub FpSpread1_ClipboardPasting(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.ClipboardPastingEventArgs) Handles FpSpread1.ClipboardPasting
  FpSpread1.ClipboardOptions = FarPoint.Win.Spread.ClipboardOptions.NoHeaders
End Sub



◎サンプルコード(C#)
private void fpSpread1_ClipboardChanging(object sender, EventArgs e)
{
  fpSpread1.ClipboardOptions = FarPoint.Win.Spread.ClipboardOptions.AllHeaders;
}

private void fpSpread1_ClipboardPasting(object sender, FarPoint.Win.Spread.ClipboardPastingEventArgs e)
{
  fpSpread1.ClipboardOptions = FarPoint.Win.Spread.ClipboardOptions.NoHeaders;
}



回复 使用道具 举报
xzhy80
注册会员   /  发表于:2016-7-29 16:01:07
板凳
http://www.grapecity.com/tools/s ... detail.asp?id=38845

カスタムセルのコピー&ペーストができない文書番号 : 38845     文書種別 : HowTo
登録日 : 2015/06/25     最終更新日 : 2015/06/25



対象製品SPREAD for Windows Forms 8.0J
詳細製品はセルのコピー&ペースト処理にあたり、.NET Frameworkにおけるオブジェクトのシリアライズ、デシリアライズ処理を利用してその動作を実現しています。

このため独自に作成されたカスタムセルについてコピー&ペースト動作を有効とされる場合には既存のセル動作と対応するよう、下記のように当該カスタムセルクラスにデシリアライズ用のコンストラクタが必要です。

◎サンプルコード(VB)
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        FpSpread1.ActiveSheet.Cells(0, 0).CellType = New CustomCellType()
        FpSpread1.ActiveSheet.Cells(0, 0).Value = "ABCDEFG"
    End Sub

End Class

' 編集用コントロールに標準のテキストボックスを利用する
' 独自のカスタムセルクラス
<Serializable()> Public Class CustomCellType

    ' 標準のセル型を継承します
    Inherits FarPoint.Win.Spread.CellType.GeneralCellType

    ' 編集用コントロールに標準のテキストボックスを利用します
    Private text As New TextBox()

    ' コンストラクタ
    Public Sub New()
        MyBase.New()
    End Sub

    ' デシリアライズ用コンストラクタ
    ' 本処理が存在しない場合、セル間のコピー&ペースト動作がただしく動作しません
    Public Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext)
        MyBase.New(info, context)
    End Sub

    ' 編集用コントロール取得
    Public Overrides Function GetEditorControl(ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal zoomFactor As Single) As System.Windows.Forms.Control
        Return text
    End Function

    ' 編集用コントロールValue取得
    Public Overrides Function GetEditorValue() As Object
        Return text.Text
    End Function

    ' 編集用コントロールへのValue値設定
    Public Overrides Sub SetEditorValue(ByVal value As Object)
        text.Text = value
    End Sub

End Class



◎サンプルコード(C#)
public partial class Form1 : Form
{
            
    public Form1()
    {
        InitializeComponent();

        CustomCellType testCell = new CustomCellType();
        fpSpread1.ActiveSheet.Cells[0,0].CellType = testCell;
        fpSpread1.ActiveSheet.Cells[0,0].Value = "ABCDEFG";
    }

}

// 標準のセル型を継承した独自のカスタムセルクラス
[Serializable()]
public class CustomCellType : FarPoint.Win.Spread.CellType.GeneralCellType
{
    // 編集用コントロールに標準のテキストボックスを利用します
    TextBox textBox = new TextBox();

    // コンストラクタ
    public CustomCellType() : base()
    {
    }

    // デシリアライズ用コンストラクタ
    // 本処理が存在しない場合、セル間のコピー&ペースト動作がただしく動作しません
    public CustomCellType(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        : base(info, context)
    {
    }

    // 編集用コントロール取得
    public override Control GetEditorControl(FarPoint.Win.Spread.Appearance appearance, float zoomFactor)
    {
        return textBox;
    }

    // 編集用コントロールValue取得
    public override object GetEditorValue()
    {
        return textBox.Text;
    }

    // 編集用コントロールへのValue値設定
    public override void SetEditorValue(object value)
    {
        textBox.Text = (string)value;
    }
}




回复 使用道具 举报
xzhy80
注册会员   /  发表于:2016-7-29 16:02:41
地板

http://www.grapecity.com/tools/s ... detail.asp?id=38838

セルの値のみのペースト機能を実装する方法文書番号 : 38838     文書種別 : HowTo
登録日 : 2015/06/25     最終更新日 : 2015/06/25



対象製品SPREAD for Windows Forms 8.0J
詳細セルのコピー&ペースト(またはカット&ペースト)を行った場合、デフォルト定義では値&#12539;書式&#12539;数式を含むすべてのデータオブジェクトを貼り付けますが、ここでは値のみをペーストする方法をいくつか紹介します。用途に合わせてご活用ください。

◎方法1:入力マップの定義による実装
デフォルトの入力マップでは、[Ctrl]+[V]による動作には「ClipboardPasteAll」が定義されています。
この定義を「ClipboardPasteValues」に変更することで、値のみのペースト機能を実装できます。

◎サンプルコード(VB)
Imports FarPoint.Win.Spread

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
  Dim im As New InputMap
  im = FpSpread1.GetInputMap(InputMapMode.WhenFocused)
  im.Put(New Keystroke(Keys.V, Keys.Control), SpreadActions.ClipboardPasteValues)
End Sub



◎サンプルコード(C#)
using FarPoint.Win.Spread;

private void Form1_Load(object sender, System.EventArgs e)
{
  InputMap im;
  im = fpSpread1.GetInputMap(InputMapMode.WhenFocused);
  im.Put(new Keystroke(Keys.V, Keys.Control), SpreadActions.ClipboardPasteValues);
}



◎方法2:ClipboardPasteメソッドの使用による実装
SheetViewクラスより提供されているClipboardPasteメソッドを利用し、貼り付けオプションを指定することで値のみのペースト機能を実装できます。

◎サンプルコード(VB)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  FpSpread1.ActiveSheet.ClipboardPaste(FarPoint.Win.Spread.ClipboardPasteOptions.Values)
End Sub



◎サンプルコード(C#)
private void button1_Click(object sender, System.EventArgs e)
{
  fpSpread1.ActiveSheet.ClipboardPaste(FarPoint.Win.Spread.ClipboardPasteOptions.Values);
}




回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-7-29 16:40:21
5#
您好,您是想做什么
回复 使用道具 举报
xzhy80
注册会员   /  发表于:2016-8-3 08:56:45
6#
留个记录,当做收藏贴用,方便以后查询
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-8-3 12:20:53
7#
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部