C1.Silverlight.Excel Namespace > XLSheet Class : Clone() Method |
After cloning a sheet, you must rename it and then add it to the book (duplicate names are not allowed).
This method is useful for applications that generate books with a large number of similar sheets.
// load book with template sheet _c1xl.Load(@"c:\temp\template.xls"); // create 12 copies of the template sheet XLSheet templateSheet = _c1xl.Sheets["Template"]; for (int month = 1; month <= 12; month++) { XLSheet newSheet = templateSheet.Clone(); newSheet.Name = month.ToString(); // rename clone newSheet[0,0].Value = month; // make changes _c1xl.Sheets.Add(newSheet); // add clone to book } // remove the template sheet and save with new name _c1xl.Sheets.Remove("Template"); _c1xl.Save(@"C:\temp\expense_report.xls");
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2