List<string> MappingFileColumnNames = new List<string>();
private void GetExcelSheetColumnNames(string FilePath, int SelectedSheet) { Microsoft.Office.Interop.Excel.Application XLApp = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook wkb = XLApp.Workbooks.Open(FilePath, 0, true); Microsoft.Office.Interop.Excel.Worksheet wks = (Microsoft.Office.Interop.Excel.Worksheet)wkb.Worksheets.get_Item(SelectedSheet); Microsoft.Office.Interop.Excel.Range DataRng = wks.UsedRange; string strCellData = ""; int colCnt = 0; for (colCnt = 1; colCnt <= DataRng.Columns.Count; colCnt++) { string strColumn = ""; strColumn = (string)(DataRng.Cells[1, colCnt] as Microsoft.Office.Interop.Excel.Range).Value2; MappingFileColumnNames.Add(strColumn); } }
DataTable dt=new DataTable(); dt.columns.add("name"); DataRow dr=null; for(int i=0;i<4:i++) { dr=dt.newrow(); dr["name"]="sai"; dt.rows.add(dr); } datagrid.itemsource=dt.defaultview;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)