Cevdet Adanali

Cevdet Adanali

  • NA
  • 5
  • 5.4k

How can i copy-paste data in richtextbox to an excel sheet?

Jan 17 2015 4:43 PM
Hallo,

I have a Form. In this form are a richtextbox with a few data in many rows (lines). I want to copy and paste all data in richtextbox in an excel sheet with a button.I can copy and paste all richtextbox data in an excel sheet but i have a problem.
data in richtextbox are there many rows (lines). When i click the button bynCopyPasteToExcel it works but all data are in cell A1
How can i copy-paste all data in richtextbox lines in excel ?

code is here :
 private void btnCopyPasteToExcel_Click(object sender, EventArgs e)

  {
  Microsoft.Office.Interop.Excel.Application uygulama = new Microsoft.Office.Interop.Excel.Application();
  uygulama.Visible = true;
  Microsoft.Office.Interop.Excel.Workbook kitap = uygulama.Workbooks.Add(System.Reflection.Missing.Value);
  Microsoft.Office.Interop.Excel.Worksheet sayfa1 = (Microsoft.Office.Interop.Excel.Worksheet)kitap.Sheets[1];
  Microsoft.Office.Interop.Excel.Range alan = (Microsoft.Office.Interop.Excel.Range)sSheets.Cells[1,1];
  alan.Value2 = richTextBox1.Text;
  }
Thanks for help...

Attachment: test_results.rar