I have one datatable i want to do filter state wise based on one particular column value
“BBB” column if “xxx”, “yyy” value found to find in “DDD” column if found USA state should get the data and print to US sheet in excel and if CANADA state found should get and write to “CA” sheet.
If “xxx” ,“yyy” column value and “DDD” column if not found in US and CA state we should skip.
NOTE: sample purpose i put only three US and CA state code it will come all the state code
Please update the linq like below to handle empty rows
if(dtInput.AsEnumerable.Where(Function (row) (row("BBB").ToString.Equals("xxx") or row("BBB").ToString.Equals("yyy")) and StateMapping("US").ToArray.Contains(row("DDD").ToString)).Count>0,dtInput.AsEnumerable.Where(Function (row) (row("BBB").ToString.Equals("xxx") or row("BBB").ToString.Equals("yyy")) and StateMapping("US").ToArray.Contains(row("DDD").ToString)).CopyToDataTable,dtInput.Clone)
if(dtInput.AsEnumerable.Where(Function (row) (row("BBB").ToString.Equals("xxx") or row("BBB").ToString.Equals("yyy")) and StateMapping("CA").ToArray.Contains(row("DDD").ToString)).Count>0,dtInput.AsEnumerable.Where(Function (row) (row("BBB").ToString.Equals("xxx") or row("BBB").ToString.Equals("yyy")) and StateMapping("CA").ToArray.Contains(row("DDD").ToString)).CopyToDataTable,dtInput.Clone)