Çalışma Sayfasını Görüntüye Dönüştür - Verilerin etrafındaki boşlukları kaldırın
Contents
[
Hide
]
Bazen uygulamalarda veya web sayfalarında çalışma sayfası görüntüleri sunmanız gerekir. Örneğin, bir Word belgesine, bir PDF dosyasına, bir PowerPoint sunumuna veya başka bir belgeye resim eklemeniz gerekebilir. Temel olarak, başka uygulamalara yapıştırılabilmesi için bir çalışma sayfasını görüntü olarak işlemek istiyorsunuz. Aspose.Cells, Microsoft Excel çalışma sayfalarını resimlere dönüştürmenizi sağlar.
Verilerin etrafındaki Boşlukları Kaldır
buAspose.Cells.Rendering.SheetRenderAPI, bir çalışma sayfasını, örneğin görüntü formatı, sayfalandırılmış sayfalar vb. belirtilen niteliklere sahip bir görüntü dosyasına dönüştürür. BMP, GIF, JPG, TIFF ve EMF dahil olmak üzere çeşitli görüntü biçimleri desteklenir.
Sayfadan görüntüye özelliğini kullandığınızda, çıktı görüntüsünün çevresinde varsayılan olarak bir boşluk, yani bir kenarlık bulunur. Kaynak çalışma sayfası için üst, alt, sol ve sağ sayfa kurulum kenar boşluklarını 0’a ayarlayarak bunu kaldırabilirsiniz.Aspose.Cells.Rendering.ImageOrPrintOptionsnitelikleri buna göre.
Aşağıdaki kod parçacığı, çıktı görüntüsündeki verilerin etrafındaki boşlukları kaldırır.
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-.NET | |
//Source directory | |
string sourceDir = RunExamples.Get_SourceDirectory(); | |
//Output directory | |
string outputDir = RunExamples.Get_OutputDirectory(); | |
// Open the template file | |
Workbook book = new Workbook(sourceDir + "Book1.xlsx"); | |
// Get the first worksheet | |
Worksheet sheet = book.Worksheets[0]; | |
LoadOptions options = new LoadOptions(); | |
options.LoadFilter = new LoadFilter(LoadDataFilterOptions.All); | |
// Specify your print area if you want | |
// Sheet.PageSetup.PrintArea = "A1:H8"; | |
// To remove the white border around the image. | |
sheet.PageSetup.LeftMargin = 0; | |
sheet.PageSetup.RightMargin = 0; | |
sheet.PageSetup.BottomMargin = 0; | |
sheet.PageSetup.TopMargin = 0; | |
// Define ImageOrPrintOptions | |
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions(); | |
imgOptions.ImageType = Drawing.ImageType.Emf; | |
// Set only one page would be rendered for the image | |
imgOptions.OnePagePerSheet = true; | |
imgOptions.PrintingPage = PrintingPageType.IgnoreBlank; | |
// Create the SheetRender object based on the sheet with its | |
// ImageOrPrintOptions attributes | |
SheetRender sr = new SheetRender(sheet, imgOptions); | |
// Convert the image | |
sr.ToImage(0, outputDir + "outputRemoveWhitespaceAroundData.emf"); |