Hi,
pls help me with my problem.
I want to open a Excel file and bind it to a exceldatasource. I bind the datasource to a Gridview without any problems. But I have to walk throw to all excel rows to do a column mapping with my sql server datasource. I've tried this one:
for (int i = 0; i < gvExcel.RowCount; i++)
{
int RowHandle = gvExcel.GetVisibleRowHandle(i);
DataRow ExcelRow = gvExcel.GetDataRow(RowHandle);
DataRow StundenRow = tADAMDataSet.tStundenImport.NewRow();
foreach (DataRow item in tADAMDataSet.tColumnMapping.Rows)
{
StundenRow[item["StundenColumn"].ToString()]+= ExcelRow[item["ExcelColumn"].ToString()].ToString();
}
tADAMDataSet.tStundenImport.Rows.Add(StundenRow);
}
but the ExcelRow is always null. Then I've read in the KBs I need to take the Nativ Excel View, can you send me a code example how this works?
DevExpress.DataAccess.Native.Excel.DataView dv = new DevExpress.DataAccess.Native.Excel.DataView(excelDataSource, ???);
thanks
br
Gregory
Hi Gregory,
If I understand your scenario correctly, you would like to bind your GridView control to the data that comes from the Excel file by using the ExcelDataSource control, am I right? In any case, it is not completely clear to me why you are iterating all the Excel rows. What kind of mapping would you like to perform? Would you please describe your scenario in greater detail so that we will be able to provide you with an appropriate solution? We look forward to hearing from you.
Hi Vasily,
yes you are correct. Will try to explain in more detail.
I have one table with some columns and want to import a excel file to this table. The excel file has columns I don't know. Therefore I want map the excel columns to the table column. I have tow combo fields, one with the excel columns, one with the table columns. The columns mapping looks like in this way:
Excel Table
Col1 Col1
Col2 Col1
Col3 Col2 and so on.
I've bound the exceldatasource to a grid view for preview. When the user has mapped the correct columns, I need to read each excel row or gridview row to put the excel data into the table with the correct column mapping.
So I go through the excel bound gridview like discribed in the first post, but my problem is, the DataRow of the excel gridview is null. I guess it is because of the exceldatasource. So I have to go through the excel nativ dataview, but I don't have the correct syntax. Or is there a other way to iterate the exceldatasource?
It is more clear for you what I want to do?
Thanks
BR
Gregory