نسخ الأشكال بين أوراق العمل
Contents
[
Hide
]
في بعض الأحيان ، تحتاج إلى نسخ العناصر الموجودة في ورقة العمل ، على سبيل المثال ، الصور والمخططات والعناصر الرسومية الأخرى ، بين أوراق العمل. Aspose.Cells يدعم هذه الميزة. يمكن نسخ المخططات والصور والكائنات الأخرى بأعلى درجة من الدقة.
تمنحك هذه المقالة فهمًا تفصيليًا لكيفية نسخ الأشكال بين أوراق العمل.
نسخ صورة من ورقة عمل إلى أخرى
لنسخ صورة من ورقة عمل إلى أخرى ، استخدم ملحقورقة العمل. الصور. إضافة طريقة كما هو موضح في نموذج التعليمات البرمجية أدناه.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Open the template file | |
Workbook workbook = new Workbook(dataDir + "sample.xlsx"); | |
// Get the Picture from the "Picture" worksheet. | |
Aspose.Cells.Drawing.Picture picturesource = workbook.Worksheets["Picture"].Pictures[0]; | |
// Save Picture to Memory Stream | |
MemoryStream ms = new MemoryStream(picturesource.Data); | |
// Copy the picture to the Result Worksheet | |
workbook.Worksheets["Result"].Pictures.Add(picturesource.UpperLeftRow, picturesource.UpperLeftColumn, ms, picturesource.WidthScale, picturesource.HeightScale); | |
// Save the Worksheet | |
workbook.Save(dataDir + "PictureCopied_out.xlsx"); |
انسخ مخططًا من ورقة عمل إلى أخرى
يوضح الكود التالي استخدامورقة العمل. الأشكال. AddCopy طريقة لنسخ مخطط من ورقة عمل إلى أخرى.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Open the template file | |
Workbook workbook = new Workbook(dataDir + "sample.xlsx"); | |
// Get the Chart from the "Chart" worksheet. | |
Aspose.Cells.Charts.Chart chartsource = workbook.Worksheets["Chart"].Charts[0]; | |
Aspose.Cells.Drawing.ChartShape cshape = chartsource.ChartObject; | |
// Copy the Chart to the Result Worksheet | |
workbook.Worksheets["Result"].Shapes.AddCopy(cshape, 20, 0, 2, 0); | |
// Save the Worksheet | |
workbook.Save(dataDir + "ChartCopied_out.xlsx"); |
نسخ عناصر التحكم وكائنات الرسم الأخرى من ورقة عمل إلى أخرى
لنسخ عناصر التحكم والكائنات الرسومية الأخرى ، استخدم ملحقورقة العمل. الأشكال. AddCopyالطريقة كما هو موضح في المثال أدناه.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Open the template file | |
Workbook workbook = new Workbook(dataDir + "sample2.xlsx"); | |
// Get the Shapes from the "Control" worksheet. | |
Aspose.Cells.Drawing.ShapeCollection shape = workbook.Worksheets["Control"].Shapes; | |
// Copy the Textbox to the Result Worksheet | |
workbook.Worksheets["Result"].Shapes.AddCopy(shape[0], 5, 0, 2, 0); | |
// Copy the Oval Shape to the Result Worksheet | |
workbook.Worksheets["Result"].Shapes.AddCopy(shape[1], 10, 0, 2, 0); | |
// Save the Worksheet | |
workbook.Save(dataDir + "ControlsCopied_out.xlsx"); |