Concerning the copied data you can access it using the Clipboard class ... Details on how to use it are available on MSDN
here
To export copied data to an excel sheet, follow these steps:
1- Convert the copied data to a 2-dimensional string (you can do this by parsing the strings in nested for loops).
2- Create an instance of Microsoft Excel and implement the DisplayInExcel method:
using System;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel;
public class ExcelDemo
{
private Excel.Application xlApp;
private Excel._Workbook xlBook;
private Excel._Worksheet xlSheet;
private object misValue = Missing.Value;
public void DisplayInExcel(string[,] Data)
{
Excel.Workbooks xlBooks;
Excel.Sheets xlSheets;
Excel.Range range;
try
{
xlApp = new Excel.Application();
xlBooks = xlApp.Workbooks;
xlBook = xlBooks.Add(Missing.Value);
xlSheets = xlBook.Worksheets;
xlSheet = (Excel._Worksheet)xlSheets.get_Item(1);
xlApp.DefaultFilePath = @"C:\test";
range = xlSheet.get_Range("A2", misValue);
range = range.get_Resize(Data.GetLength(0), Data.GetLength(1));
range.set_Value(Missing.Value, Data);
xlSheet.Rows.AutoFit();
xlSheet.Columns.AutoFit();
string timeStamp = DateTime.Now.ToString("ddMMyyyymmss");
string save = string.Concat("test1", timeStamp, ".xls");
xlBook.SaveAs(save, Excel.XlFileFormat.xlWorkbookNormal, misValue,
misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue,
misValue, misValue, misValue);
}
catch(Exception ex)
{
}
}
}