How to export data from DataGridView to Excel including header as column C# Visual Studio
//you can change dgv_data_baru to your own DataGridView name //put these using above the class but first you have to import the referrence, there are many easy guides about it on google using Microsoft.Office.Interop.Excel; using _Excel1 = Microsoft.Office.Interop.Excel; using System.IO; private void ImportDataGridViewDataToExcelSheet() { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Excel Documents (*.xls)|*.xls"; sfd.FileName = "Inventory_Adjustment_Export.xls"; if (sfd.ShowDialog() == DialogResult.OK) { _Excel1.Application xlexcel = new _Excel1.Application(); _Excel1.Application xlApp; _Excel1.Workbook xlWorkBook; _Excel1.Worksheet xlWorkSheet; object misValue = System.Reflection.Missing.Value; xlApp = new _Excel1.Application(); xlWorkBook = xlApp.Workbooks.Add(misValue...
Comments
Post a Comment