C1.Xaml.Excel アセンブリ > C1.Xaml.Excel 名前空間 > XLSheet クラス : Clone() メソッド |
シートの複製を作成したら、シートの名前を変更してから、ブックに追加する必要があります。名前の重複は許可されていません。
このメソッドは、類似のシートを多数含むブックを生成するアプリケーションで便利です。
// テンプレートシートを含むブックをロードします _c1xl.Load(@"c:\temp\template.xls"); // テンプレートシートのコピーを 12 個作成します XLSheet templateSheet = _c1xl.Sheets["Template"]; for (int month = 1; month <= 12; month++) { XLSheet newSheet = templateSheet.Clone(); newSheet.Name = month.ToString(); // 複製の名前を変更します newSheet[0,0].Value = month; // 変更を行います _c1xl.Sheets.Add(newSheet); // 複製をブックに追加します } // テンプレートシートを削除し、新しい名前で保存します _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