Farklı Görüntü Biçimlerine Çalışsayı Dönüştürme

Çalışsayıyı Görüntüye Dönüştürme

Çalışma sayfaları analiz etmek istediğiniz verileri içerebilir. Örneğin, bir çalışma sayfası parametreleri, toplamları, yüzdeleri, istisnaları ve hesaplamaları içerebilir.

Bir geliştirici olarak, çalışma sayfalarını görüntü olarak sunmanız gerekebilir. Örneğin, bir çalışma sayfasının bir görüntüsünü bir uygulamada veya web sayfasında kullanmanız gerekebilir. Bir çalışma sayfasını bir Microsoft Word belgesine, bir PDF dosyasına, bir PowerPoint sunumuna veya başka bir belge türüne eklemek isteyebilirsiniz. Basitçe söylemek gerekirse, bir çalışma sayfasını bir görüntü olarak oluşturmak istiyorsunuz ki başka bir yerde kullanabilesiniz.

Aspose.Cells, Excel çalışma sayfalarını görüntülere dönüştürmeyi destekler. Bu özelliği kullanabilmek için programınıza veya projenize Aspose.Cells.Rendering ad alanını içe aktarmanız gerekir. Render ve yazdırma için birkaç değerli sınıf içerir, örneğin SheetRenderImageOrPrintOptions ve diğerleri.

Aspose.Cells.Rendering.ISheetRender sınıfı, bir çalışma sayfasını görüntü olarak oluşturacak. Değişik özelliklere veya seçeneklere sahip bir çalışma sayfasını farklı görüntü dosyalarına dönüştürebilen bir ToImage metoduna sahiptir. Çeşitli görüntü biçimleri desteklenir, örneğin BMP, PNG, GIF, JPG, JPEG, TIFF, EMF.

Aşağıdaki kod örneği, bir Excel dosyasındaki bir çalışma sayfasını bir görüntü dosyasına dönüştürmenin nasıl yapıldığını gösterir.

PNG Biçimi

Lütfen, örnek kodunu, örnek Excel dosyasını ve çıktı PNG Görüntülerini inceleyin.

Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Source directory path.
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path.
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Path of input Excel file.
U16String sampleConvertingWorksheetToDifferentImageFormats = srcDir + u"sampleConvertingWorksheetToDifferentImageFormats.xlsx";
// Create an empty workbook.
Workbook workbook(sampleConvertingWorksheetToDifferentImageFormats);
// Access first worksheet.
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Create image or print options object.
ImageOrPrintOptions imgOptions;
// Specify the image format.
imgOptions.SetImageType(ImageType::Png);
// Specify horizontal and vertical resolution
imgOptions.SetHorizontalResolution(200);
imgOptions.SetVerticalResolution(200);
// Render the sheet with respect to specified image or print options.
SheetRender sr(worksheet, imgOptions);
// Get page count.
int pageCount = sr.GetPageCount();
// Create string builder object for string concatenations.
std::string sb;
// Render each page to png image one by one.
for (int i = 0; i < pageCount; i++)
{
// Clear string builder and create output image path with string concatenations.
sb = "";
sb += outDir.ToUtf8();
sb += "outputConvertingWorksheetToImagePNG_";
sb += std::to_string(i);
sb += ".png";
// Get the output image path.
U16String outputPNG(sb.c_str());
// Convert worksheet to png image.
sr.ToImage(i, outputPNG);
}
Aspose::Cells::Cleanup();

TIFF Biçimi

Lütfen, örnek kodunu, örnek Excel dosyasını ve çıktı TIFF Görüntüsünü inceleyin.

Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Source directory path.
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path.
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Path of input Excel file.
U16String sampleConvertingWorksheetToDifferentImageFormats = srcDir + u"sampleConvertingWorksheetToDifferentImageFormats.xlsx";
// Create an empty workbook.
Workbook workbook(sampleConvertingWorksheetToDifferentImageFormats);
// Access first worksheet.
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Create image or print options object.
ImageOrPrintOptions imgOptions;
// Specify the image format.
imgOptions.SetImageType(ImageType::Tiff);
// Specify horizontal and vertical resolution
imgOptions.SetHorizontalResolution(200);
imgOptions.SetVerticalResolution(200);
// Render the sheet with respect to specified image or print options.
SheetRender sr(worksheet, imgOptions);
// Get the output image path.
U16String outputTiff = outDir + u"outputConvertingWorksheetToImageTiff.tiff";
// Convert worksheet to tiff image.
sr.ToTiff(outputTiff);
Aspose::Cells::Cleanup();

Çalışma Sayfasını SVG’ye Dönüştürme

SVG, Ölçeklenebilir Vektör Grafikleri anlamına gelir. SVG, iki boyutlu vektör grafikleri için XML standartlarına dayanan bir spesifikasyondur. 1999’dan beri World Wide Web Consortium (W3C) tarafından geliştirilen açık bir standarttır.

Aspose.Cells for C++ sürümünden itibaren, çalışma sayfalarını SVG görüntüye dönüştürebilmektedir.

Bu özelliği kullanabilmek için programınıza veya projenize Aspose.Cells.Rendering ad alanını içe aktarmanız gerekir. Render ve yazdırma için birkaç değerli sınıf içerir, örneğin ISheetRenderIImageOrPrintOptions, ve diğerleri.

Aspose.Cells.Rendering.IImageOrPrintOptions sınıfı, çalışma sayfasının SVG biçiminde kaydedileceğini belirtir. Aşağıdaki kod parçası, bir Excel dosyasındaki bir çalışma sayfasını SVG bir görüntü dosyasına dönüştürmeyi gösterir.

Lütfen, örnek kodunu, örnek Excel dosyasını ve çıktı SVG Görüntülerini inceleyin.

Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Source directory path.
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path.
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Path of input Excel file.
U16String sampleConvertingWorksheetToDifferentImageFormats = srcDir + u"sampleConvertingWorksheetToDifferentImageFormats.xlsx";
// Create an empty workbook.
Workbook workbook(sampleConvertingWorksheetToDifferentImageFormats);
// Access first worksheet.
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Create image or print options object.
ImageOrPrintOptions imgOptions;
// Specify the image format.
imgOptions.SetImageType(ImageType::Svg);
// Specify horizontal and vertical resolution
imgOptions.SetHorizontalResolution(200);
imgOptions.SetVerticalResolution(200);
// Render the sheet with respect to specified image or print options.
SheetRender sr(worksheet, imgOptions);
// Get page count.
int pageCount = sr.GetPageCount();
// Create string builder object for string concatenations.
std::string sb;
// Render each page to png image one by one.
for (int i = 0; i < pageCount; i++)
{
// Clear string builder and create output image path with string concatenations.
sb = "";
sb += outDir.ToUtf8();
sb += "outputConvertingWorksheetToImageSVG_";
sb += std::to_string(i);
sb += ".svg";
// Get the output image path.
U16String outputSvg(sb.c_str());
// Convert worksheet to svg image.
sr.ToImage(i, outputSvg);
}
Aspose::Cells::Cleanup();