GanttView provides various methods to export its content in the desired formats such as XML and MS projects.
Let us discuss how to export GanttView and its content to various formats.
To serialize grid contents into an XML document, you can simply use SaveXml method of the C1GanttView class. The SaveXml method provides various overloads for saving the contents as listed below.
Overload | Description |
---|---|
SaveXml(string fileName) | To save the contents into an XML file. |
SaveXml(string fileName, System.Text.Encoding encoding) | Saves the contents into an XML file with encoding. |
SaveXml(System.IO.Stream stream) | Saves the contents into an IO stream object. |
SaveXml(System.IO.Stream stream, System.Text.Encoding encoding) | Saves the contents into an IO stream object with encoding. |
SaveXml(System.Xml.XmlWriter writer) | Saves the contents into an XmlWriter object. |
The following code illustrates how the SaveXml method can be used to save the contents into an XML file. This code exports all the project schedules to an XML file named gantt.
C# |
Copy Code
|
---|---|
SaveFileDialog dlg = new SaveFileDialog(); dlg.DefaultExt = ".xml"; dlg.FileName = "gantt"; dlg.Filter = "XML files|*.xml|All files|*.*"; dlg.Title = "Save Gantt View As Xml File"; if (dlg.ShowDialog().Value) { gv.SaveXml(dlg.FileName); } |
The GanttView control supports exporting GanttView schedules to MS Project using ExportToMsProjectXml method of the C1GanttView class.
Use the following code to save GanttView schedules to MS project.
C# |
Copy Code
|
---|---|
SaveFileDialog dlg = new SaveFileDialog(); dlg.DefaultExt = ".xml"; dlg.FileName = "ganttMSProject"; dlg.Filter = "XML files|*.xml|All files|*.*"; dlg.Title = "Save Gantt View As MsProject Xml File"; gv.ExportToMsProjectXml(); |