public void CopyRangeToClipboard() { Clipboard.SetText("xltoolbox test", TextDataFormat.Text); svm.CopyToClipboard(); // Check if the clipboard contains Excel's Biff12 format Assert.IsTrue(Clipboard.ContainsData("Biff12")); Clipboard.Clear(); }
/// <summary> /// Copies the current selection to the clipboard. /// </summary> private bool CopySelection() { using (SelectionViewModel selection = new SelectionViewModel(Instance.Default.Application)) { selection.CopyToClipboard(); } return(true); }
/// <summary> /// Performs the actual export for a given selection. This method is /// called by the <see cref="ExportSelection"/> method and during /// a batch export process. /// </summary> /// <param name="widthInPoints">Width of the output graphic.</param> /// <param name="heightInPoints">Height of the output graphic.</param> /// <param name="fileName">Destination filename (must contain placeholders).</param> private void ExportWithDimensions(double widthInPoints, double heightInPoints) { if (Preset == null) { Logger.Fatal("ExportWithDimensions: No export preset!"); throw new InvalidOperationException("Cannot export without export preset"); } Logger.Info("ExportWithDimensions: Preset: {0}", Preset); // Copy current selection to clipboard SelectionViewModel.CopyToClipboard(); // Get a metafile view of the clipboard content // Must not dispose the WorkingClipboard instance before the metafile // has been drawn on the bitmap canvas! Otherwise the metafile will not draw. Metafile emf; using (WorkingClipboard clipboard = new WorkingClipboard()) { Logger.Info("ExportWithDimensions: Get metafile"); emf = clipboard.GetMetafile(); switch (Preset.FileType) { case FileType.Emf: ExportEmf(emf); break; case FileType.Png: case FileType.Tiff: ExportViaFreeImage(emf, widthInPoints, heightInPoints); break; default: throw new NotImplementedException(String.Format( "No export implementation for {0}.", Preset.FileType)); } } }