We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Export Charts to JPG

In an older Post from March I found out that you planed to include a feature for exporting charts like with the Excel VBA Chart.Export()-Method. I’m wondering if you have allready included this feature and if not if you have a plan till when it wil be implemented.

We did investigate for the feature of exporting charts to JPG. But it’s too complex and we postponed this feature.

We will do it in the future but it will not be available in a short time.

Aspose.Excel is discarded now and is replaced with a much advanced product Aspose.Cells which supports all the legacy features of Aspose.Excel as well as latest features available in different versions of MS Excel. Now you can save chart to JPG and lot of other formats as well. Here is an example which creates a chart and then saves it to JPG.

// Instantiate a workbook
Workbook workbook = new Workbook();

// Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];

// Set columns title 
worksheet.Cells[0, 0].Value = "X";
worksheet.Cells[0, 1].Value = "Y";

// Random data shall be used for generating the chart
Random R = new Random();

// Create random data and save in the cells
for (int i = 1; i < 21; i++)
    worksheet.Cells[i, 0].Value = i;
    worksheet.Cells[i, 1].Value = 0.8;

for (int i = 21; i < 41; i++)
    worksheet.Cells[i, 0].Value = i - 20;
    worksheet.Cells[i, 1].Value = 0.9;
// Add a chart to the worksheet
int idx = worksheet.Charts.Add(ChartType.LineWithDataMarkers, 1, 3, 20, 20);

// Access the newly created chart
Chart chart = worksheet.Charts[idx];

// Set chart style
chart.Style = 3;

// Set autoscaling value to true
chart.AutoScaling = true;

// Set foreground color white
chart.PlotArea.Area.ForegroundColor = Color.White;

// Set Properties of chart title
chart.Title.Text = "Sample Chart";

// Set chart type
chart.Type = ChartType.LineWithDataMarkers;

// Set Properties of categoryaxis title
chart.CategoryAxis.Title.Text = "Units";

//Set Properties of nseries
int s2_idx = chart.NSeries.Add("A2: A2", true);
int s3_idx = chart.NSeries.Add("A22: A22", true);

// Set IsColorVaried to true for varied points color
chart.NSeries.IsColorVaried = true;

// Set properties of background area and series markers
chart.NSeries[s2_idx].Area.Formatting = FormattingType.Custom;
chart.NSeries[s2_idx].Marker.Area.ForegroundColor = Color.Yellow;
chart.NSeries[s2_idx].Marker.Border.IsVisible = false;

// Set X and Y values of series chart
chart.NSeries[s2_idx].XValues = "A2: A21";
chart.NSeries[s2_idx].Values = "B2: B21";

// Set properties of background area and series markers
chart.NSeries[s3_idx].Area.Formatting = FormattingType.Custom;
chart.NSeries[s3_idx].Marker.Area.ForegroundColor = Color.Green;
chart.NSeries[s3_idx].Marker.Border.IsVisible = false;

// Set X and Y values of series chart
chart.NSeries[s3_idx].XValues = "A22: A41";
chart.NSeries[s3_idx].Values = "B22: B41";


Have a look on the following section of documents which provides more details about working with charts:
Converting Worksheet to Different Image Formats

You can download the latest version of this product from the following link for trials:
Aspose.Cells for .NET (Latest Version)

We have created a runnable solution which can be used for testing the product features without writing any code. It can be downloaded here.