Export data from Windows Forms DataGridView and TextBox to Excel
问题 I have a Form that contains number of TextBox controls and a DataGridView . I want to export the data from that form to an excel file. I am using this code it work perfectly for DataGridView but I don't know how to export TextBox controls data. private void copyAlltoClipboard() { dataGridView1.SelectAll(); DataObject dataObj = dataGridView1.GetClipboardContent(); if (dataObj != null) Clipboard.SetDataObject(dataObj); } try { copyAlltoClipboard(); Microsoft.Office.Interop.Excel.Application