lavint
1
Hi,
I am aware of the following method:
dt.Select(“[Column Name] =”+“'”+blah+“'” ).CopyToDataTable
but I have a dynamic column name so using column index will be a better approach.
I got the column name using:
cName = dt.Columns(10).ColumnName
can someone direct me who to put this variable in dt.select?
I tried
dt1.Select(credit “> 0”).CopyToDataTable
dt1.Select(“credit > 0”).CopyToDataTable
They don’t work…
Thanks!
Lavina
Edit: I actually got it! ha - for those who have the same problem:
dt1.Select(“[” + cName + “] > 0”).CopyToDataTable
MAHESH1
(MAHESHKUMAR JV)
2
@lavint
dt.Select(“[Column Name] ='”+dt.Columns(Column_Index).ColumnName.ToString+“'” ).CopyToDataTable
Regards,
Mahesh
AkankshaP
(Akanksha)
3
Hello Mahesh ,
If the excel file does not have headers and I want to filter data on the basis of column index , then could you please tell me how to do it?
MAHESH1
(MAHESHKUMAR JV)
4
@AkankshaP
First Read the Excel sheet and store it in a DataTable. Let us take as dta.
Now Filter the DataTable by using below Query.
dtb= (From p In dta.Select
Where p(Column_Index).ToString.Equals("StringValue")
Select p).ToArray.CopyToDataTable
dtb is the Filtered DataTable.
Column_Index-> integer
Regards,
Mahesh
4 Likes
AkankshaP
(Akanksha)
5
Hello Mahesh ,
Thanks. I tried this solution , and its working fine.
Thanks for your instant support.
Regards,
Akanksha
system
(system)
Closed
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.