We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Export Gantt Grid as Image

Thread ID:

Created:

Updated:

Platform:

Replies:

148527 Oct 23,2019 03:06 PM UTC Oct 25,2019 12:49 PM UTC WPF 1
loading
Tags: GanttControl
Sérgio Rodrigues Costa
Asked On October 23, 2019 03:06 PM UTC

I am trying to export the Gantt control grid using the sample "ExportTo Image_2017" sample solution as starting point, but the grid image always comes out misssing a part of it. I would like to have the complete grid on the image.
Could you guys point me in the direction, so I can complete the idea?
I´m sending the image output as an attachment.
Thanks in advance.

The code:
public void ExporGridtBtn_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            RenderTargetBitmap bmp;
            BitmapEncoder bitmapEncoder;
            int width;
 
            GanttControl Gantt = this.AssociatedObject.TabControl.SelectedContent as GanttControl;
 
            GanttGrid tmp = Gantt.FindName<GanttGrid>("PART_GanttGrid");
            ScrollViewer chartGrid = tmp.FindName<ScrollViewer>("PART_ScrollViewer");
 
            Gantt.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Gantt.Arrange(new Rect(new Size(Gantt.DesiredSize.Width, Gantt.DesiredSize.Height)));
            bmp = new RenderTargetBitmap(
               (int)Gantt.DesiredSize.Width, (int)Gantt.DesiredSize.Height, 96, 96, PixelFormats.Default);
 
            bmp.Render(chartGrid);
 
            width = (int)(Gantt.DesiredSize.Width - chartGrid.ActualWidth);
 
            CroppedBitmap crpBmp = new CroppedBitmap(bmpnew Int32Rect(0, 0, width, (int)Gantt.DesiredSize.Height));
 
 
            bitmapEncoder = new PngBitmapEncoder();
            bitmapEncoder.Frames.Add(BitmapFrame.Create(crpBmp));
 
            SaveFileDialog saveFileDialog = new SaveFileDialog();
 
            saveFileDialog.FileName = "Untitled";
            saveFileDialog.DefaultExt = "png";
            saveFileDialog.Filter = "PNG Files (*.png)|*.png|Jpeg Files (*.jpg)|*.jpg|Bitmap Files (*.bmp)|*.bmp|All files (*.*)|*.*";
            saveFileDialog.FilterIndex = 1;
 
            if (saveFileDialog.ShowDialog() == true)
            {
                using (Stream stream = saveFileDialog.OpenFile())
                {
                    bitmapEncoder.Save(stream);
                    stream.Close();
                    System.Diagnostics.Process.Start(saveFileDialog.FileName);
                }
            }
        }


Attachment: Untitled_e5e3548a.zip

Rachel A [Syncfusion]
Replied On October 25, 2019 12:49 PM UTC

Hi Sérgio, 
 
Greetings from Syncfusion. 
 
We can export only visible view of the Gantt grid columns in order to export full view of Gantt grid (with expand), we have to export it individually.

Also we can view the Gantt chart with grid in single by loading both images in pdf document.  We have prepared the sample based on this and you can download the sample from the following location.
 
 
 
Thanks, 
Rachel. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon