Kaynak Aralığın Satır Yüksekliklerini Hedef Aralığa Kopyala

Contents
[ ]

Aşağıdaki örnek kod, kaynak aralığın satır yüksekliklerini hedef aralığa kopyalamak için PasteType.RowHeights numarasını nasıl kullanacağını açıklamaktadır. Bu kod tarafından oluşturulan çıktı excel dosyasını Microsoft Excel’de açtığınızda, hedef aralığın satır yüksekliklerinin tam olarak kaynak aralığın satır yükseklikleriyle aynı olduğunu göreceksiniz.

// 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);
// Create workbook object
Workbook workbook = new Workbook();
// Source worksheet
Worksheet srcSheet = workbook.Worksheets[0];
// Add destination worksheet
Worksheet dstSheet = workbook.Worksheets.Add("Destination Sheet");
// Set the row height of the 4th row. This row height will be copied to destination range
srcSheet.Cells.SetRowHeight(3, 50);
// Create source range to be copied
Range srcRange = srcSheet.Cells.CreateRange("A1:D10");
// Create destination range in destination worksheet
Range dstRange = dstSheet.Cells.CreateRange("A1:D10");
// PasteOptions, we want to copy row heights of source range to destination range
PasteOptions opts = new PasteOptions();
opts.PasteType = PasteType.RowHeights;
// Copy source range to destination range with paste options
dstRange.Copy(srcRange, opts);
// Write informative message in cell D4 of destination worksheet
dstSheet.Cells["D4"].PutValue("Row heights of source range copied to destination range");
// Save the workbook in xlsx format
workbook.Save(dataDir + "output_out.xlsx", SaveFormat.Xlsx);