# grid-exporting

> Grid populated with numeric data and exported to Word via GridWordConverter with DocIO-rendered headers and footers.

**Framework:** winforms  **Component:** Grid  **Variant:** exporting

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/winforms/grid-exporting.json
```

**Install Package(s)**

```bash
dotnet add package Syncfusion.Grid.Windows
```

**Notes**

- Syncfusion release: 2026 Volume 2 (v34.1.29)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/grid-exporting/Form1.cs

```cs
#region Copyright Syncfusion Inc. 2001 - 2015
//
//  Copyright Syncfusion Inc. 2001 - 2015. All rights reserved.
//
//  Use of this code is subject to the terms of our license.
//  A copy of the current license can be obtained at any time by e-mailing
//  licensing@syncfusion.com. Any infringement will be prosecuted under
//  applicable laws. 
//
#endregion

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Drawing.Imaging;

using Syncfusion.Windows.Forms.Grid;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using System.Collections.Generic;
using Syncfusion.Windows.Forms;
using System.Collections.Specialized;
using System.Diagnostics;
using Syncfusion.Drawing;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf;
using Syncfusion.Diagnostics;
using Syncfusion.XlsIO;
using Syncfusion.GridExcelConverter;
using Syncfusion.GridHelperClasses;
using System.Text;
using DemoCommon.Grid;
using Syncfusion.Telemetry;

namespace ExportingDemo
{
	public class Form1 : GridDemoForm
    {
        #region API Definition
        private Syncfusion.Windows.Forms.Grid.GridControl gridControl1;
        private System.Windows.Forms.Panel panel1;
        private GroupBox groupBox1;
        private ButtonAdv buttonAdv1;
        private Syncfusion.Windows.Forms.Tools.XPTaskBar xpTaskBar1;
        private Syncfusion.Windows.Forms.Tools.XPTaskBarBox xpTaskBarBox4;
        private Syncfusion.Windows.Forms.Tools.GradientPanel gradientPanel4;
        private IContainer components;
        #endregion

        #region Constructor
        public Form1()
		{
			InitializeComponent();
            if (DpiAware.GetCurrentDpi() > 96)
            {
                this.CaptionBarHeight = (int)DpiAware.LogicalToDeviceUnits(this.CaptionBarHeight);
            }
            this.gridControl1.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
           // this.gridControl1.AllowProportionalColumnSizing = true;
			GridModel model = gridControl1.Model;
			model.Options.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation;            
			GridFontInfo boldFont = new GridFontInfo();
			boldFont.Bold = true;			
			boldFont.Size = 10;
			boldFont.Underline = true;
			gridControl1.Rows.DefaultSize += 2;
			int boldfontRowHeight = gridControl1.Rows.DefaultSize + 6;

          
			model.Options.ControllerOptions = GridControllerOptions.All;
			model.Options.DataObjectConsumerOptions = GridDataObjectConsumerOptions.All;
			GridStyleInfo standard = model.BaseStylesMap["Standard"].StyleInfo;
			GridStyleInfo header = model.BaseStylesMap["Header"].StyleInfo;
			GridStyleInfo rowHeader = model.BaseStylesMap["Row Header"].StyleInfo;
			GridStyleInfo colHeader = model.BaseStylesMap["Column Header"].StyleInfo;
			header.Interior = new BrushInfo(SystemColors.Control);
			rowHeader.Interior = new BrushInfo(SystemColors.Control);			
			standard.Font.Facename = "Helvetica";
			standard.VerticalAlignment = GridVerticalAlignment.Middle;
            this.gridControl1.RowCount = 50;
            this.xpTaskBarBox4.Collapsed = true;
            this.xpTaskBarBox4.AfterAnimation += new EventHandler(xpTaskBarBox4_AfterAnimation);

            //tab key navigation set as false to move the next control
            this.gridControl1.WantTabKey = false;
            this.gridControl1.ColWidths[0] = (int)DpiAware.LogicalToDeviceUnits(35);

        }

        void xpTaskBarBox4_AfterAnimation(object sender, EventArgs e)
        {
            this.gridControl1.BeginInit();
            this.gridControl1.Model.ClearCells(GridRangeInfo.Table(), true);
            this.gridControl1.ResetColWidthEntries();
            this.gridControl1.ResetRowHeightEntries();
            if (xpTaskBarBox4.Collapsed == false)
            {
                this.populateTheGridWord();
            }
            this.gridControl1.EndInit();
        }
        #endregion                      

        #region Desginer Stuffs
        /// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            Syncfusion.Windows.Forms.Grid.GridCellInfo gridCellInfo1 = new Syncfusion.Windows.Forms.Grid.GridCellInfo();
            Syncfusion.Windows.Forms.Grid.GridCellInfo gridCellInfo2 = new Syncfusion.Windows.Forms.Grid.GridCellInfo();
            Syncfusion.Windows.Forms.Grid.GridCellInfo gridCellInfo3 = new Syncfusion.Windows.Forms.Grid.GridCellInfo();
            Syncfusion.Windows.Forms.Grid.GridCellInfo gridCellInfo4 = new Syncfusion.Windows.Forms.Grid.GridCellInfo();
            Syncfusion.Windows.Forms.Grid.GridCellInfo gridCellInfo5 = new Syncfusion.Windows.Forms.Grid.GridCellInfo();
            Syncfusion.Windows.Forms.Grid.GridCellInfo gridCellInfo6 = new Syncfusion.Windows.Forms.Grid.GridCellInfo();
            Syncfusion.Windows.Forms.Grid.GridCellInfo gridCellInfo7 = new Syncfusion.Windows.Forms.Grid.GridCellInfo();
            Syncfusion.Windows.Forms.Grid.GridCellInfo gridCellInfo8 = new Syncfusion.Windows.Forms.Grid.GridCellInfo();
            this.gridControl1 = new Syncfusion.Windows.Forms.Grid.GridControl();
            this.panel1 = new System.Windows.Forms.Panel();
            this.xpTaskBar1 = new Syncfusion.Windows.Forms.Tools.XPTaskBar();
            this.xpTaskBarBox4 = new Syncfusion.Windows.Forms.Tools.XPTaskBarBox();
            this.gradientPanel4 = new Syncfusion.Windows.Forms.Tools.GradientPanel();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.buttonAdv1 = new Syncfusion.Windows.Forms.ButtonAdv();
            ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit();
            this.panel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.xpTaskBar1)).BeginInit();
            this.xpTaskBar1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.xpTaskBarBox4)).BeginInit();
            this.xpTaskBarBox4.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.gradientPanel4)).BeginInit();
            this.gradientPanel4.SuspendLayout();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // gridControl1
            // 
            this.gridControl1.DpiAware = true;
            this.gridControl1.AlphaBlendSelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(94)))), ((int)(((byte)(171)))), ((int)(((byte)(222)))));
            //this.gridControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            //| System.Windows.Forms.AnchorStyles.Left) 
            //| System.Windows.Forms.AnchorStyles.Right)));
            this.gridControl1.Dock = DockStyle.Fill;
            this.gridControl1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.gridControl1.ColCount = 9;
            this.gridControl1.ColWidthEntries.AddRange(new Syncfusion.Windows.Forms.Grid.GridColWidth[] {
            new Syncfusion.Windows.Forms.Grid.GridColWidth(0, 35),
            new Syncfusion.Windows.Forms.Grid.GridColWidth(3, 179),
            new Syncfusion.Windows.Forms.Grid.GridColWidth(4, 196)});
            this.gridControl1.DefaultGridBorderStyle = Syncfusion.Windows.Forms.Grid.GridBorderStyle.Solid;
            this.gridControl1.Font = new System.Drawing.Font("Segoe UI", 8.5F);
            this.gridControl1.ForeColor = System.Drawing.Color.MidnightBlue;
            gridCellInfo1.Col = -1;
            gridCellInfo1.Row = -1;
            gridCellInfo1.StyleInfo.Font.Bold = false;
            gridCellInfo1.StyleInfo.Font.Facename = "Segoe UI";
            gridCellInfo1.StyleInfo.Font.Italic = false;
            gridCellInfo1.StyleInfo.Font.Size = 8.5F;
            gridCellInfo1.StyleInfo.Font.Strikeout = false;
            gridCellInfo1.StyleInfo.Font.Underline = false;
            gridCellInfo1.StyleInfo.Font.Unit = System.Drawing.GraphicsUnit.Point;
            gridCellInfo2.Col = -1;
            gridCellInfo2.Row = -1;
            gridCellInfo2.StyleInfo.Font.Bold = false;
            gridCellInfo2.StyleInfo.Font.Facename = "Segoe UI";
            gridCellInfo2.StyleInfo.Font.Italic = false;
            gridCellInfo2.StyleInfo.Font.Size = 8.5F;
            gridCellInfo2.StyleInfo.Font.Strikeout = false;
            gridCellInfo2.StyleInfo.Font.Underline = false;
            gridCellInfo2.StyleInfo.Font.Unit = System.Drawing.GraphicsUnit.Point;
            gridCellInfo3.Col = -1;
            gridCellInfo3.Row = -1;
            gridCellInfo3.StyleInfo.Font.Bold = false;
            gridCellInfo3.StyleInfo.Font.Facename = "Segoe UI";
            gridCellInfo3.StyleInfo.Font.Italic = false;
            gridCellInfo3.StyleInfo.Font.Size = 8.5F;
            gridCellInfo3.StyleInfo.Font.Strikeout = false;
            gridCellInfo3.StyleInfo.Font.Underline = false;
            gridCellInfo3.StyleInfo.Font.Unit = System.Drawing.GraphicsUnit.Point;
            gridCellInfo4.Col = -1;
            gridCellInfo4.Row = -1;
            gridCellInfo4.StyleInfo.Font.Bold = false;
            gridCellInfo4.StyleInfo.Font.Facename = "Segoe UI";
            gridCellInfo4.StyleInfo.Font.Italic = false;
            gridCellInfo4.StyleInfo.Font.Size = 8.5F;
            gridCellInfo4.StyleInfo.Font.Strikeout = false;
            gridCellInfo4.StyleInfo.Font.Underline = false;
            gridCellInfo4.StyleInfo.Font.Unit = System.Drawing.GraphicsUnit.Point;
            gridCellInfo5.Col = -1;
            gridCellInfo5.Row = -1;
            gridCellInfo5.StyleInfo.Font.Bold = false;
            gridCellInfo5.StyleInfo.Font.Facename = "Segoe UI";
            gridCellInfo5.StyleInfo.Font.Italic = false;
            gridCellInfo5.StyleInfo.Font.Size = 8.5F;
            gridCellInfo5.StyleInfo.Font.Strikeout = false;
            gridCellInfo5.StyleInfo.Font.Underline = false;
            gridCellInfo5.StyleInfo.Font.Unit = System.Drawing.GraphicsUnit.Point;
            gridCellInfo6.Col = -1;
            gridCellInfo6.Row = -1;
            gridCellInfo6.StyleInfo.Font.Bold = false;
            gridCellInfo6.StyleInfo.Font.Facename = "Segoe UI";
            gridCellInfo6.StyleInfo.Font.Italic = false;
            gridCellInfo6.StyleInfo.Font.Size = 8.5F;
            gridCellInfo6.StyleInfo.Font.Strikeout = false;
            gridCellInfo6.StyleInfo.Font.Underline = false;
            gridCellInfo6.StyleInfo.Font.Unit = System.Drawing.GraphicsUnit.Point;
            gridCellInfo7.Col = -1;
            gridCellInfo7.Row = -1;
            gridCellInfo7.StyleInfo.Font.Bold = false;
            gridCellInfo7.StyleInfo.Font.Facename = "Segoe UI";
            gridCellInfo7.StyleInfo.Font.Italic = false;
            gridCellInfo7.StyleInfo.Font.Size = 8.5F;
            gridCellInfo7.StyleInfo.Font.Strikeout = false;
            gridCellInfo7.StyleInfo.Font.Underline = false;
            gridCellInfo7.StyleInfo.Font.Unit = System.Drawing.GraphicsUnit.Point;
            gridCellInfo8.Col = -1;
            gridCellInfo8.Row = -1;
            gridCellInfo8.StyleInfo.Font.Bold = false;
            gridCellInfo8.StyleInfo.Font.Facename = "Segoe UI";
            gridCellInfo8.StyleInfo.Font.Italic = false;
            gridCellInfo8.StyleInfo.Font.Size = 8.5F;
            gridCellInfo8.StyleInfo.Font.Strikeout = false;
            gridCellInfo8.StyleInfo.Font.Underline = false;
            gridCellInfo8.StyleInfo.Font.Unit = System.Drawing.GraphicsUnit.Point;
            this.gridControl1.GridCells.AddRange(new Syncfusion.Windows.Forms.Grid.GridCellInfo[] {
            gridCellInfo1,
            gridCellInfo2,
            gridCellInfo3,
            gridCellInfo4,
            gridCellInfo5,
            gridCellInfo6,
            gridCellInfo7,
            gridCellInfo8});
            this.gridControl1.ThemesEnabled = true;
            //this.gridControl1.GridOfficeScrollBars = Syncfusion.Windows.Forms.OfficeScrollBars.Metro;
            //this.gridControl1.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
            this.gridControl1.DefaultRowHeight = (int)DpiAware.LogicalToDeviceUnits(20.0f);
            this.gridControl1.DefaultColWidth = (int)DpiAware.LogicalToDeviceUnits(70.0f);
            this.gridControl1.HorizontalThumbTrack = true;
            this.gridControl1.Location = new System.Drawing.Point(11, 7);
            //this.gridControl1.MetroScrollBars = true;
            this.gridControl1.Name = "gridControl1";
            this.gridControl1.Properties.BackgroundColor = System.Drawing.Color.White;
            this.gridControl1.Properties.ForceImmediateRepaint = false;
            this.gridControl1.Properties.GridLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(208)))), ((int)(((byte)(215)))), ((int)(((byte)(229)))));
            this.gridControl1.Properties.MarkColHeader = false;
            this.gridControl1.Properties.MarkRowHeader = false;
            this.gridControl1.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.gridControl1.RowCount = 30;
            this.gridControl1.RowHeightEntries.AddRange(new Syncfusion.Windows.Forms.Grid.GridRowHeight[] {
            new Syncfusion.Windows.Forms.Grid.GridRowHeight(0, 21)});
            this.gridControl1.SerializeCellsBehavior = Syncfusion.Windows.Forms.Grid.GridSerializeCellsBehavior.SerializeIntoCode;
            this.gridControl1.Size = new System.Drawing.Size(657, 442);
            this.gridControl1.SmartSizeBox = false;
            this.gridControl1.TabIndex = 0;
            this.gridControl1.VerticalThumbTrack = true;
            this.gridControl1.SaveCellText += new Syncfusion.Windows.Forms.Grid.GridCellTextEventHandler(this.gridControl1_SaveCellText);
            this.gridControl1.SaveCellFormattedText += new Syncfusion.Windows.Forms.Grid.GridCellTextEventHandler(this.gridControl1_SaveCellFormattedText);
            // 
            // panel1
            // 
            this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.panel1.BackColor = System.Drawing.Color.White;
            this.panel1.Controls.Add(this.gridControl1);
            this.panel1.Controls.Add(this.xpTaskBar1);
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(1001, 468);
            this.panel1.TabIndex = 4;
            // 
            // xpTaskBar1
            // 
            this.xpTaskBar1.Dock = DockStyle.Right;
            this.xpTaskBar1.AutoSize = true;
            this.xpTaskBar1.BackColor = System.Drawing.Color.White;
            this.xpTaskBar1.BeforeTouchSize = new System.Drawing.Size(310, 200);
            this.xpTaskBar1.BorderColor = System.Drawing.Color.Black;
            this.xpTaskBar1.Controls.Add(this.xpTaskBarBox4);
            this.xpTaskBar1.Location = new System.Drawing.Point(685, 7);
            this.xpTaskBar1.MetroColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(158)))), ((int)(((byte)(218)))));
            this.xpTaskBar1.MinimumSize = new System.Drawing.Size(0, 0);
            this.xpTaskBar1.Name = "xpTaskBar1";
            this.xpTaskBar1.Size = new System.Drawing.Size(310, 200);
            this.xpTaskBar1.TabIndex = 20;
            // 
            // xpTaskBarBox4
            // 
            this.xpTaskBarBox4.BackColor = System.Drawing.Color.White;
            this.xpTaskBarBox4.Controls.Add(this.gradientPanel4);
            this.xpTaskBarBox4.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.xpTaskBarBox4.HeaderBackColor = System.Drawing.Color.DarkGray;
            this.xpTaskBarBox4.HeaderForeColor = System.Drawing.Color.White;
            this.xpTaskBarBox4.HeaderImageIndex = -1;
            this.xpTaskBarBox4.HitTaskBoxArea = false;
            this.xpTaskBarBox4.HotTrackColor = System.Drawing.Color.Empty;
            this.xpTaskBarBox4.ItemBackColor = System.Drawing.Color.White;
            this.xpTaskBarBox4.Location = new System.Drawing.Point(0, 0);
            this.xpTaskBarBox4.Name = "xpTaskBarBox4";
            this.xpTaskBarBox4.PreferredChildPanelHeight = (int)DpiAware.LogicalToDeviceUnits(109.0f);
            this.xpTaskBarBox4.Size = new System.Drawing.Size(310, 140);
            this.xpTaskBarBox4.TabIndex = 3;
            this.xpTaskBarBox4.Text = "WORD";
            // 
            // gradientPanel4
            // 
            this.gradientPanel4.AutoSize = true;
            this.gradientPanel4.BackColor = System.Drawing.Color.White;
            this.gradientPanel4.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.gradientPanel4.Controls.Add(this.groupBox1);
            this.gradientPanel4.Location = new System.Drawing.Point(2, 29);
            this.gradientPanel4.Name = "gradientPanel4";
            this.gradientPanel4.Size = new System.Drawing.Size(306, 109);
            this.gradientPanel4.TabIndex = 0;
            // 
            // groupBox1
            // 
            this.groupBox1.BackColor = System.Drawing.Color.White;
            this.groupBox1.Controls.Add(this.buttonAdv1);
            this.groupBox1.Location = new System.Drawing.Point(7, 3);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(297, 96);
            this.groupBox1.TabIndex = 14;
            this.groupBox1.TabStop = false;
            // 
            // buttonAdv1
            // 
            this.buttonAdv1.Appearance = Syncfusion.Windows.Forms.ButtonAppearance.Metro;
            this.buttonAdv1.FlatStyle = FlatStyle.Flat;
            this.buttonAdv1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(22)))), ((int)(((byte)(165)))), ((int)(((byte)(220)))));
            this.buttonAdv1.BeforeTouchSize = new System.Drawing.Size(121, 32);
            this.buttonAdv1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.buttonAdv1.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.buttonAdv1.ForeColor = System.Drawing.Color.White;
            this.buttonAdv1.IsBackStageButton = false;
            this.buttonAdv1.Location = new System.Drawing.Point(85, 48);
            this.buttonAdv1.Name = "buttonAdv1";
            this.buttonAdv1.Size = new System.Drawing.Size(121, 32);
            this.buttonAdv1.TabIndex = 14;
            this.buttonAdv1.Text = "    Word Export";
            this.buttonAdv1.Click += new System.EventHandler(this.buttonAdv1_Click);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(1013, 468);
            this.Controls.Add(this.panel1);
            this.MinimumSize = new System.Drawing.Size(800, 400);
            this.Name = "Form1";
            this.Text = "Word Export";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).EndInit();
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.xpTaskBar1)).EndInit();
            this.xpTaskBar1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.xpTaskBarBox4)).EndInit();
            this.xpTaskBarBox4.ResumeLayout(false);
            this.xpTaskBarBox4.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.gradientPanel4)).EndInit();
            this.gradientPanel4.ResumeLayout(false);
            this.groupBox1.ResumeLayout(false);
            this.ResumeLayout(false);

		}
        private void Form1_Load(object sender, System.EventArgs e)
        {
            this.populateTheGridWord();
            this.gridControl1.TableStyle.TextColor = Color.DimGray;
        }
        #region Dispose
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
        #endregion
		#endregion

        #region Main
        /// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		public static void Main()
        {
			Telemetry.Disable();
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(Syncfusion.Licensing.DemoCommon.FindLicenseKey());
            # if SyncfusionFramework1_1 || SyncfusionFramework2_0  
			Application.EnableVisualStyles();			
              # endif
			Application.Run(new Form1());
		}
        #endregion

        #region Methods

        private void populateTheGridWord()
        {
            this.gridControl1.SuspendLayout();
            Random rand = new Random();
            for (int i = 1; i <= gridControl1.RowCount; i++)
                for (int j = 1; j <= gridControl1.ColCount; j++)
                {
                    this.gridControl1[i, j].Text = (10 * (i * j)).ToString();
                    this.gridControl1[0, j].Text = "C" + j.ToString();
                    this.gridControl1[i, 0].Text = "R" + i.ToString();
                }
            this.gridControl1.ColWidths[0] = (int)DpiAware.LogicalToDeviceUnits(35);
            this.gridControl1.ResumeLayout();
        }

       
        private void gridControl1_SaveCellText(object sender, Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs e)
		{
			TraceUtil.TraceCurrentMethodInfo(e);
			ParseText(e);
		}

		private void gridControl1_SaveCellFormattedText(object sender, GridCellTextEventArgs e)
		{
			TraceUtil.TraceCurrentMethodInfo(e);
			ParseText(e);
		}

		void ParseText(GridCellTextEventArgs e)
		{
			// By default, the grid will display a warning message box informing the user
			// the entered value is not valid and the user will have to change the value.
			//
			// In this event handler we change the grid defaults behavior such that
			// when the user enters a value that does not fit the cells CellValueType,
			// the input text is accepted and no warning message is shown.
			if (e.Handled || e.Style.Tag == null || !e.Style.Tag.Equals("Custom"))
				return;

			System.Globalization.CultureInfo ci = e.Style.CultureInfo;
			System.Globalization.NumberFormatInfo nfi = ci != null ? ci.NumberFormat : null; 
			try
			{
				e.Style.CellValue = GridCellValueConvert.Parse(e.Text, e.Style.CellValueType, nfi, e.Style.Format);
			}
			catch (Exception ex)
			{
				if (ex is FormatException || ex.InnerException is FormatException)
				{
					e.Style.CellValue = e.Text;
					// possibly could also change CellValueType here 
					e.Style.CellValueType = typeof(string);
					Console.WriteLine("Changed e.Style.CellValueType = typeof(string) for " + e.Style.Identity.ToString());
					// - or -
					// you could also further analyze the input text and assign a type
					// that fits the input text, e.g.
					// e.Style.CellValueType = typeof(datetime);
					// - or - 
					// e.Style.CellValueType = typeof(decimal);
					// etc.
				}
				else
					throw;
			}
			e.Handled = true;
		}
        #endregion
              
        #region Word
        private void buttonAdv1_Click(object sender, EventArgs e)
        {
                GridWordConverter converter = new GridWordConverter(true, true);
                converter.DrawHeader += new GridWordConverterBase.DrawDocHeaderFooterEventHandler(converter_DrawHeader);
                converter.DrawFooter += new GridWordConverterBase.DrawDocHeaderFooterEventHandler(converter_DrawFooter);
                converter.GridToWord("Sample.doc", gridControl1);
#if !NETCORE
            System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo("Sample.doc");
            info.UseShellExecute = true;
            System.Diagnostics.Process.Start(info);
#else
            ProcessStartInfo psi = new ProcessStartInfo
            {
                FileName = "cmd",
                WindowStyle = ProcessWindowStyle.Hidden,
                UseShellExecute = false,
                CreateNoWindow = true,
                Arguments = "/c start Sample.doc"
            };
            Process.Start(psi);
#endif
        }

        void converter_DrawFooter(object sender, DocHeaderFooterEventArgs e)
        {
            e.Footer.AddParagraph().AppendText("Copyright 2001-2008");
        }

        void converter_DrawHeader(object sender, DocHeaderFooterEventArgs e)
        {
            e.Header.AddParagraph().AppendText("Syncfusion Inc.");
        }

#endregion
        
    }
}

```
