Sayfa Yapısı Ayarlarını Kaynak Çalışma Sayfasından Hedef Çalışma Sayfasına Kopyalayın
Contents
[
Hide
]
Olası Kullanım Senaryoları
Çalışma kitabına yeni bir sayfa eklediğinizde, varsayılan Sayfa Yapısı ayarlarını içerir. Ayarları aktarmanız gereken zamanlar olabilir (Sayfa ayarı) bir çalışma sayfasından başka bir çalışma sayfasına. Bu belge, Aspose.Cells API’leri kullanılarak Sayfa Yapısı ayarlarının bir çalışma sayfasından diğerine nasıl kopyalanacağını açıklar.
Sayfa Yapısı Ayarlarını Kaynak Çalışma Sayfasından Hedef Çalışma Sayfasına Kopyalayın
Aşağıdaki örnek kod, Sayfa Yapısı ayarlarının bir çalışma sayfasından diğerine nasıl kopyalanacağını gösterir.PageSetup.Copy() yöntem. Lütfen referans için aşağıdaki örnek koda ve konsol çıktısına bakın.
Basit kod
This file contains hidden or 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-Java | |
//Converting integer enums to string enums | |
HashMap<Integer, String> paperSizeTypes = new HashMap<Integer, String>(); | |
paperSizeTypes.put(PaperSizeType.PAPER_A_3_EXTRA_TRANSVERSE, "PAPER_A_3_EXTRA_TRANSVERSE"); | |
paperSizeTypes.put(PaperSizeType.PAPER_LETTER, "PAPER_LETTER"); | |
//Create workbook | |
Workbook wb = new Workbook(); | |
//Add two test worksheets | |
wb.getWorksheets().add("TestSheet1"); | |
wb.getWorksheets().add("TestSheet2"); | |
//Access both worksheets as TestSheet1 and TestSheet2 | |
Worksheet TestSheet1 = wb.getWorksheets().get("TestSheet1"); | |
Worksheet TestSheet2 = wb.getWorksheets().get("TestSheet2"); | |
//Set the Paper Size of TestSheet1 to PaperA3ExtraTransverse | |
TestSheet1.getPageSetup().setPaperSize(PaperSizeType.PAPER_A_3_EXTRA_TRANSVERSE); | |
//Print the Paper Size of both worksheets | |
System.out.println("Before Paper Size: " + paperSizeTypes.get(TestSheet1.getPageSetup().getPaperSize())); | |
System.out.println("Before Paper Size: " + paperSizeTypes.get(TestSheet2.getPageSetup().getPaperSize())); | |
System.out.println(); | |
//Copy the PageSetup from TestSheet1 to TestSheet2 | |
TestSheet2.getPageSetup().copy(TestSheet1.getPageSetup(), new CopyOptions()); | |
//Print the Paper Size of both worksheets | |
System.out.println("After Paper Size: " + paperSizeTypes.get(TestSheet1.getPageSetup().getPaperSize())); | |
System.out.println("After Paper Size: " + paperSizeTypes.get(TestSheet2.getPageSetup().getPaperSize())); | |
System.out.println(); |
Konsol Çıkışı
Before Paper Size: PAPER_A_3_EXTRA_TRANSVERSE
Before Paper Size: PAPER_LETTER
After Paper Size: PAPER_A_3_EXTRA_TRANSVERSE
After Paper Size: PAPER_A_3_EXTRA_TRANSVERSE