ImageOrPrintOptions.ChartImageType
ImageOrPrintOptions.ChartImageType property
Indicate the chart imagetype when converting. default value: PNG.
[Obsolete("Chart and Shape are always rendered as vector elements(e.g. point, line) for rendering quality.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public ImageFormat ChartImageType { get; set; }
Remarks
NOTE: This member is now obsolete. Instead, Chart and Shape are always rendered as vector elements(e.g. point, line) for rendering quality. This property will be removed 12 months later since June 2022. Aspose apologizes for any inconvenience you may have experienced.
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using Aspose.Cells.Rendering;
using Aspose.Cells.Charts;
using Aspose.Cells.Drawing;
using System;
using System.IO;
public class ImageOrPrintOptionsPropertyChartImageTypeDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
// Add a worksheet with a chart
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells["A1"].Value = "Sample Data";
worksheet.Cells["A2"].Value = 10;
worksheet.Cells["A3"].Value = 20;
worksheet.Cells["A4"].Value = 30;
// Add a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);
Chart chart = worksheet.Charts[chartIndex];
chart.NSeries.Add("A2:A4", true);
try
{
// Create ImageOrPrintOptions instance
ImageOrPrintOptions options = new ImageOrPrintOptions();
// Display the current ChartImageType value
Console.WriteLine("Current ChartImageType: " + options.ImageType);
// Set different image type for chart rendering
options.ImageType = ImageType.Png;
Console.WriteLine("ChartImageType set to: " + options.ImageType);
// Create a SheetRender to demonstrate the property effect
SheetRender renderer = new SheetRender(worksheet, options);
// Render the chart to a memory stream
MemoryStream stream = new MemoryStream();
renderer.ToImage(0, stream);
Console.WriteLine("Chart rendered successfully with ChartImageType: " + options.ImageType);
Console.WriteLine("Image size: " + stream.Length + " bytes");
// Save the workbook
workbook.Save("ChartImageTypeDemo.xlsx");
Console.WriteLine("Workbook saved successfully.");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
See Also
- class ImageOrPrintOptions
- namespace Aspose.Cells.Rendering
- assembly Aspose.Cells