I have two excel i want to copy one excel data to another excel , i used write range but it wont worked because second excel having formula and formatting is there .
I tried modern activity as well but i couldnt able to copy/paste two excel , single excel i can.
So i couldnt able to get solution, please help me anyone for this.
// The source DataTable from which you want to copy data
DataTable sourceDataTable = /* your source DataTable */;
// The target DataTable where you want to copy data
DataTable targetDataTable = /* your target DataTable */;
// Create the target DataTable if it is empty, and define its structure accordingly
if (targetDataTable.Rows.Count == 0)
{
// Here you can clone the structure from sourceDataTable if needed
targetDataTable = sourceDataTable.Clone();
}
// Define the LINQ query to select the desired data from the source
var dataToCopy = from row in sourceDataTable.AsEnumerable()
select row;
// Now, add the selected data to the target DataTable
foreach (var row in dataToCopy)
{
targetDataTable.ImportRow(row); // This will keep the formatting and any original properties
}