Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,34 @@ class Program
{
static void Main(string[] args)
{
//Initialize ExcelEngine
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Initialize application
IApplication application = excelEngine.Excel;

//Set the default version as Xlsx
application.DefaultVersion = ExcelVersion.Xlsx;

// Initialize XlsIORenderer
//Initialize XlsIORenderer
application.XlsIORenderer = new XlsIORenderer();

//Set converter chart image format to PNG
//Set converter chart image format to PNG or JPEG
application.XlsIORenderer.ChartRenderingOptions.ImageFormat = ExportImageFormat.Png;

//Set the chart image quality to best
application.XlsIORenderer.ChartRenderingOptions.ScalingMode = ScalingMode.Best;

//Open existing workbook with chart
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream);
IWorksheet worksheet = workbook.Worksheets[0];

//Access the chart from the worksheet
IChart chart = worksheet.Charts[0];

#region Save
//Saving the workbook
//Exporting the chart as image
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Image.png"), FileMode.Create, FileAccess.Write);
chart.SaveAsImage(outputStream);
#endregion
Expand Down