Note that there are some explanatory texts on larger screens.

plurals
  1. POExport datagrid to Excel using Dialog Box on Winform
    primarykey
    data
    text
    <p>I'm looking for how to export a <strong>datagrid</strong> (or dataSet) (not datagridview) to excel using dialog box which saves data in specific place, I am working on <strong>VS 2003 <em>winform</em> NOT webform</strong>. Nothing in the NET :'( ... PLEASE help me I'ts Urgent <em>THANK YOU</em> this my code :</p> <p><strong>i just need too open a dialog box to let the user choose where he want put his file</strong></p> <pre><code>private void button2_Click(object sender, System.EventArgs e) { #region string data = null; int i = 0; int j = 0; Excel.Application xlApp ; Excel.Workbook xlWorkBook ; Excel.Worksheet xlWorkSheet ; object misValue = System.Reflection.Missing.Value; xlApp = new Excel.ApplicationClass(); xlWorkBook = xlApp.Workbooks.Add(misValue); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); for (i = 0; i &lt;= dsSelectionListeDiffere.Tables[0].Rows.Count - 1; i++) { for (j = 0; j &lt;= dsSelectionListeDiffere.Tables[0].Columns.Count - 1; j++) { data = dsSelectionListeDiffere.Tables[0].Rows[i].ItemArray[j].ToString(); xlWorkSheet.Cells[i + 1, j + 1] = data; } } xlWorkBook.SaveAs("csharp.net-informations.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); xlWorkBook.Close(true, misValue, misValue); xlApp.Quit(); releaseObject(xlWorkSheet); releaseObject(xlWorkBook); releaseObject(xlApp); MessageBox.Show("Excel file created , you can find the file c:\\csharp.net-informations.xls"); #endregion } </code></pre> <p>and i have another code it works too : </p> <pre><code>#region //// lblMessage.Visible = true; //// lblMessage.Text = ""; // // Export all the details // try // { // // Get the datatable to export // DataTable dt = dsSelectionListeDiffere.Tables[0].Copy(); // dsSelectionListeDiffere = FrmFonctionPrincipale.getListeDifferesParClient(1); // // Export all the details to Excel // // // RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win"); // objExport.ExportDetails(dt, Export.ExportFormat.Excel, "C:\\EmployeesInfo.xls"); // MessageBox.Show("Exporté Avec Succès dans C:\\EmployeesInfo.xls"); // } // catch(Exception Ex) // { // MessageBox.Show(Ex.Message); //// lblMessage.Text = Ex.Message; // } #endregion </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload