http://gcdn.grapecity.com/showtopic-3512.html中的如下代码:
private void fpSpread1_ClipboardPasting(object sender, FarPoint.Win.Spread.ClipboardPastingEventArgs e)
{
FarPoint.Win.Spread.Model.CellRange cr = default(FarPoint.Win.Spread.Model.CellRange);
string textdata = null;
string[] a = null;
string[] b = null;
int rowcount = 0;
int colcount = 0;
cr = fpSpread1.Sheets[0].GetSelection(0);
if (cr.RowCount > 1 | cr.ColumnCount > 1)
{
e.Handled = true;
if (System.Windows.Forms.Clipboard.GetDataObject().GetDataPresent(System.Windows.Forms.DataFormats.Text))
{
textdata = (string)System.Windows.Forms.Clipboard.GetDataObject().GetData(System.Windows.Forms.DataFormats.Text);
a = textdata.Split(new char[] { (char)13 });
rowcount = a.Length - 1;
b = a[0].Split(new char[] { (char)9 });
colcount = b.Length;
for (int i = cr.Row; i <= cr.Row + cr.RowCount - 1; i += rowcount)
{
for (int x = 0; x <= rowcount - 1; x++)
{
b = a[x].Split(new char[] { (char)9 });
for (int j = cr.Column; j <= cr.Column + cr.ColumnCount - 1; j += colcount)
{
for (int y = 0; y <= colcount - 1; y++)
{
string myStr;
myStr = b[0];
fpSpread1.Sheets[0].SetValue(i + x, j + y, myStr.Trim((char)10, (char)30));
}
}
}
}
}
}
}
}
和http://gcdn.grapecity.com/showto ... ;postid=27711#27711 的代码冲突。剪贴板上的内容乱了。麻烦您试一下! |