Sayfa Düzeni ve Yazdırma Seçenekleri
Bazen geliştiricilerin baskı işlemini kontrol etmek için sayfa düzeni ve yazdırma ayarlarını yapılandırması gerekir. Sayfa düzeni ve yazdırma ayarları çeşitli seçenekler sunar ve Aspose.Cells for Python via .NET’de tamamen desteklenir.
Bu makale, Visual Studio.Net’te nasıl bir konsol uygulaması oluşturulacağını ve birkaç basit satır kod kullanarak Aspose.Cells for Python via .NET API’si ile bir çalışma sayfasına sayfa düzeni ve yazdırma seçenekleri uygulamayı gösterir.
Sayfa ve Yazdırma Ayarları İle Çalışma
Bu örnekte, Microsoft Excel’de bir çalışma kitabı oluşturduk ve Aspose.Cells for Python via .NET kullanarak sayfa düzeni ve yazdırma seçeneklerini ayarladık.
Aspose.Cells Kullanarak Sayfa Düzeni Seçenekleri Ayarlama
Öncelikle Microsoft Excel’de basit bir çalışma sayfası oluşturun. Sonra ona sayfa düzeni seçenekleri uygulayın. Kodu yürüttüğünüzde, aşağıdaki ekran görüntüsünde görülen gibi Sayfa Düzeni seçeneklerini değiştirir.
Çıktı dosyası. |
---|
![]() |
- Microsoft Excel’de bazı veriler içeren bir çalışma sayfası oluşturun:
- Microsoft Excel’de yeni bir çalışma kitabı açın.
- Bazı veriler ekleyin.
- Sayfa düzeni seçeneklerini ayarlayın: Ayarları dosyaya uygulayın. Yeni ayarların uygulanmadan önceki varsayılan seçeneklerin ekran görüntüsü aşağıda verilmiştir.
Varsayılan sayfa düzeni seçenekleri. |
---|
![]() |
from aspose.cells import PageOrientationType, PaperSizeType, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Open the template workbook | |
workbook = Workbook(dataDir + "CustomerReport.xlsx") | |
# Accessing the first worksheet in the Excel file | |
worksheet = workbook.worksheets[0] | |
# Setting the orientation to Portrait | |
worksheet.page_setup.orientation = PageOrientationType.PORTRAIT | |
# Setting the scaling factor to 100 | |
# worksheet.PageSetup.Zoom = 100; | |
# OR Alternately you can use Fit to Page Options as under | |
# Setting the number of pages to which the length of the worksheet will be spanned | |
worksheet.page_setup.fit_to_pages_tall = 1 | |
# Setting the number of pages to which the width of the worksheet will be spanned | |
worksheet.page_setup.fit_to_pages_wide = 1 | |
# Setting the paper size to A4 | |
worksheet.page_setup.paper_size = PaperSizeType.PAPER_A4 | |
# Setting the print quality of the worksheet to 1200 dpi | |
worksheet.page_setup.print_quality = 1200 | |
# Setting the first page number of the worksheet pages | |
worksheet.page_setup.first_page_number = 2 | |
# Save the workbook | |
workbook.save(dataDir + "PageSetup_out.xlsx") |
Yazdırma seçeneklerini ayarlama
Sayfa ayarı ayarları ayrıca kullanıcıların çalışma sayfalarının nasıl yazdırılacağını kontrol etmelerine olanak tanıyan birkaç yazdırma seçeneği (aynı zamanda sayfa seçenekleri de denir) sağlar. Kullanıcılara şunları yapma olanağı tanırlar:
- Bir çalışma sayfasının belirli bir baskı alanını seçin.
- Başlıkları yazdırın.
- Izgaraları yazdırın.
- Satır/sütun başlıklarını yazdırın.
- Taslak kalitesine ulaşın.
- Yorumları yazdırın.
- Hücre hatalarını yazdırın.
- Sayfa sıralamasını tanımlayın.
Aşağıdaki örnek yeni seçeneklerin uygulandığı dosyaya (Yukarıdaki örnekte oluşturulan PageSetup.xls) yazdırma seçeneklerini uygular. Aşağıdaki ekran görüntüsü, yeni seçenekler uygulanmadan önceki varsayılan yazdırma seçeneklerini gösterir.
Giriş belgesi |
---|
![]() |
Kodun çalıştırılması yazdırma seçeneklerini değiştirir. |
Çıktı dosyası |
---|
![]() |
from aspose.cells import PrintCommentsType, PrintErrorsType, PrintOrderType, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Open the template workbook | |
workbook = Workbook(dataDir + "PageSetup.xlsx") | |
# Accessing the first worksheet in the Excel file | |
worksheet = workbook.worksheets[0] | |
pageSetup = worksheet.page_setup | |
# Specifying the cells range (from A1 cell to E30 cell) of the print area | |
pageSetup.print_area = "A1:E30" | |
# Defining column numbers A & E as title columns | |
pageSetup.print_title_columns = "$A:$E" | |
# Defining row numbers 1 as title rows | |
pageSetup.print_title_rows = "$1:$2" | |
# Allowing to print gridlines | |
pageSetup.print_gridlines = True | |
# Allowing to print row/column headings | |
pageSetup.print_headings = True | |
# Allowing to print worksheet in black & white mode | |
pageSetup.black_and_white = True | |
# Allowing to print comments as displayed on worksheet | |
pageSetup.print_comments = PrintCommentsType.PRINT_IN_PLACE | |
# Allowing to print worksheet with draft quality | |
pageSetup.print_draft = True | |
# Allowing to print cell errors as N/A | |
pageSetup.print_errors = PrintErrorsType.PRINT_ERRORS_NA | |
# Setting the printing order of the pages to over then down | |
pageSetup.order = PrintOrderType.OVER_THEN_DOWN | |
# Save the workbook | |
workbook.save(dataDir + "PageSetup_Print_out.xlsx") |