Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
300
I created a win chart and want to add it to excel
posted

I want to let users resize the control and import it into Excel without losing its dimensions (aka want it to have optimal resolution, etc without stretching etc.).

I see examples of how to add it to excel - not a problem but it gets stretched.

 

For instance this will export the grid + the chart but I want to retain the chart size or at least its dimensions (aka width - height ratio).  For instance - I want to start the image at Cell [0, 4] and I want it to span as many cells as required to display correctly. 

using Infragistics.Documents.Excel;

using Infragistics.UltraChart.Resources.Appearance;

using Infragistics.UltraChart.Shared.Styles;

using Infragistics.Win.UltraWinGrid.ExcelExport;

                   

...

Workbook wb = new Workbook();

wb.SetCurrentFormat(WorkbookFormat.Excel2007);

Worksheet ws = wb.Worksheets.Add("Chart");

exporter.Export(breakdownGrid, ws);

MemoryStream ms = new MemoryStream();

LineChart.SaveTo(ms, Infragistics.UltraChart.Shared.Styles.RenderingType.Image);

WorksheetImage image = new WorksheetImage(Image.FromStream(ms));

image.PositioningMode = ShapePositioningMode.DontMoveOrSizeWithCells;

image.TopLeftCornerCell = ws.Rows[0].Cells[4];

image.TopLeftCornerPosition = new PointF(0.0F, 0.0F);

image.BottomRightCornerCell = ws.Rows[20].Cells[30+4];

image.BottomRightCornerPosition = new PointF(100.0F, 100.0F);

ws.Shapes.Add(image);

wb.Save(dialog.FileName);

ms.Dispose();