PasteFromStreamEx(
SrcStream: IIOStream;
PasteMode: TabPasteMode;
[SkipEmptyCells: Boolean = False;]
[Transpose: Boolean = False]);
PasteFromStreamEx(
SrcStream: System.IO.Stream;
PasteMode: Prognoz.Platform.Interop.Tab.TabPasteMode;
SkipEmptyCells: Boolean;
Transpose: Boolean);
SrcStream. The stream, from which data is inserted.
PasteMode. Insert mode.
SkipEmptyCells. Indicates whether empty cells are skipped.
Transpose. Indicates whether data should be transposed on insert.
The PasteFromStreamEx method inserts data from the specified stream to the current range according to the set insert parameters.
Before executing the method the cursor in the stream must be set to the start position: IIOStream.Position=0. Data must be copied to the stream by means of the ITabRange.CopyToStream method.
If the inserted data contains empty cells, and the SkipEmptyCells parameter is set to True, formulas, formatting and comments are inserted for these cells.
Executing the example requires that the repository contains a form with the Button1 and Button2 buttons, the UiTabSheet component named UiTabSheet1 and any visualizers, for which UiTabSheet1 is set as a data source.
Class TESTForm: Form
UiTabSheet1: UiTabSheet;
TabSheetBox1: TabSheetBox;
Button1: Button;
Button2: Button;
MStream: IMemoryStream;
TSheet: ITabSheet;
Sub TESTFormOnCreate(Sender: Object; Args: IEventArgs);
Begin
TSheet := UiTabSheet1.TabSheet;
MStream := New MemoryStream.Create;
End Sub TESTFormOnCreate;
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
MStream.Clear;
TSheet.View.Selection.Range.CopyToStream(MStream);
End Sub Button1OnClick;
Sub Button2OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
If MStream.Size > 0 Then
MStream.Position := 0;
TSheet.View.Selection.Range.PasteFromStreamEx(MStream, TabPasteMode.Values, True, True);
End If;
End Sub Button2OnClick;
End Class TESTForm;
When the form is started, the stream is initialized in the memory, which will be used for data exchange. Clicking the Button1 button copies data of the currently selected table range to the stream. Clicking the Button2 button special pastes to the currently selected range: only range values, the range is transposed, formatting, comments and formulas of empty cells are skipped.
The requirements and result of the Fore.NET Example execution match with those in the Fore Example. Use Fore.NET analogs instead of Fore components.
Imports Prognoz.Platform.Interop.Tab;
Public Partial Class TESTForm: Prognoz.Platform.Forms.Net.ForeNetForm
Public Constructor TESTForm();
Begin
InitializeComponent();
End Constructor;
TSheet: TabSheet;
MStream: System.IO.MemoryStream = New System.IO.MemoryStream();
Private Sub TESTForm_Activated(sender: System.Object; e: System.EventArgs);
Var
TStyle: ITabTableStyle;
Begin
TSheet := uiTabSheetNet1.TabSheetUi.TabSheet;
End Sub;
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Begin
MStream.SetLength(0);
TSheet.View.Selection.Range.CopyToStream(MStream);
End Sub;
Private Sub button2_Click(sender: System.Object; e: System.EventArgs);
Begin
If MStream.Length > 0 Then
MStream.Position := 0;
TSheet.View.Selection.Range.PasteFromStreamEx(MStream, TabPasteMode.tpmValues, True, True);
End If;
End Sub;
End Class;
See also: