İstenilen Genişlik ve Yükseklikte Çalışma Sayfası veya Grafik Dışa Aktarma (C++)
Contents
[
Hide
]
Aspose.Cells’ı kullanarak çalışma sayfasını veya şekli istenen genişlik ve yükseklikte bir görüntüye dışa aktarabilirsiniz. Dışa aktarılan görüntünün istenen genişlik ve yüksekliğini ayarlamak için ImageOrPrintOptions.SetDesiredSize() yöntemini sağlar. Genişlik ve yükseklik piksel biriminde belirtilir.
Aşağıdaki kod çalışma sayfasını 400x400 boyutunda bir görüntüye dışa aktarır.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Source directory
U16String sourceDir = u"..\\Data\\01_SourceDirectory\\";
// Output directory
U16String outputDir = u"..\\Data\\02_OutputDirectory\\";
// Create workbook object from source file
Workbook workbook(sourceDir + u"sampleWorksheetToImageDesiredSize.xlsx");
// Access first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Set image or print options
ImageOrPrintOptions opts;
opts.SetOnePagePerSheet(true);
opts.SetImageType(Drawing::ImageType::Png);
opts.SetDesiredSize(400, 400, false);
// Render sheet into image
SheetRender sr(worksheet, opts);
sr.ToImage(0, outputDir + u"outputWorksheetToImageDesiredSize.png");
std::cout << "Worksheet rendered to image successfully!" << std::endl;
Aspose::Cells::Cleanup();
}