To copy the rows of a sheet from one book to a second book, complete the following steps:
C# |
Copy Code
|
---|---|
C1XLBook wb = new C1XLBook(); wb.Load(@"C:\test.xlsx"); |
C# |
Copy Code
|
---|---|
C1XLBook xb = new C1XLBook(); xb.Sheets.Add("Test"); |
C# |
Copy Code
|
---|---|
XLSheet source = wb.Sheets[0]; XLSheet dest = xb.Sheets["Test"]; for (int row = 0; row <= source.Rows.Count - 1; row++) { for (int col = 0; col <= source.Columns.Count - 1; col++) { dest[row, col].Value = source[row, col].Value; } } |
C# |
Copy Code
|
---|---|
// Save and open the file xb.Save(@"C:\test2.xlsx"); System.Diagnostics.Process.Start(@"C:\test2.xlsx"); |