不太明白您说的,是要把一个sheet 页当成模板复制到其他页?
复制整个sheet
- private void button1_Click(object sender, EventArgs e)
- {
- FarPoint.Win.Spread.SheetView s = new FarPoint.Win.Spread.SheetView();
- s.Cells[0, 0].Text = "test";
- FarPoint.Win.Spread.DrawingSpace.FourWayArrowShape sh = new FarPoint.Win.Spread.DrawingSpace.FourWayArrowShape();
- sh.Name = "Arrow";
- s.AddShape(sh);
- fpSpread1.Sheets.Add(CopySheet(s));
- }
- public FarPoint.Win.Spread.SheetView CopySheet(FarPoint.Win.Spread.SheetView sheet)
- {
- FarPoint.Win.Spread.SheetView newSheet = null;
- if (sheet != null)
- {
- newSheet = (FarPoint.Win.Spread.SheetView)FarPoint.Win.Serializer.LoadObjectXml(typeof(FarPoint.Win.Spread.SheetView), FarPoint.Win.Serializer.GetObjectXml(sheet, "CopySheet"), "CopySheet");
- }
- return newSheet;
- }
复制代码
区域复制粘贴
- Random r = new Random();
- int i, j;
- DialogResult dlg;
- for (i = 0; i <= 3; i++)
- {
- for (j = 0; j <= 3; j++)
- {
- fpSpread1.ActiveSheet.SetValue(i, j, r.Next() -100000);
- }
- }
- dlg = MessageBox.Show("Do you want to copy the data to the clipboard?", "ClipboardCopy", MessageBoxButtons.YesNo);
- if (dlg == DialogResult.Yes)
- {
- fpSpread1.ActiveSheet.AddSelection(0, 0, 3, 3);
- fpSpread1.ActiveSheet.ClipboardCopy();
- }
- dlg = MessageBox.Show("Do you want to paste the data from the clipboard? If yes, let's clear the data first.", "Clear", MessageBoxButtons.YesNo);
- if (dlg == DialogResult.Yes)
- {
- fpSpread1.ActiveSheet.Cells[0, 0, 5, 5].Text = "";
- }
- dlg = MessageBox.Show("Now we're ready to paste!!", "ClipboardPaste", MessageBoxButtons.YesNo);
- if (dlg == DialogResult.Yes)
- {
- fpSpread1.ActiveSheet.ClipboardPaste();
- }
复制代码 |