[DevExpress] Excel로 내보내기

2592 단어 DevExpress
주요 코드:
        #region  Excel

        /// <summary>

        ///  Excel

        /// <para>eg:GridHelper.ToXls(gcLamp,string.Format("{0}_ .xls", DateTime.Now.ToString("yyyyMMdd")));</para>

        /// </summary>

        /// <param name="grid">GridControl</param>

        /// <param name="fileName"> Excel </param>

        public static void ToXls(this GridControl grid, string fileName)

        {

            SaveFileDialog _saveFileDialog = new SaveFileDialog();

            _saveFileDialog.Title = " Excel";

            _saveFileDialog.Filter = "Excel (*.xls)|*.xls";

            _saveFileDialog.FileName = fileName;

            DialogResult _dialogResult = _saveFileDialog.ShowDialog();

            if (_dialogResult == DialogResult.OK)

            {

                XlsExportOptions _options = new XlsExportOptions();

                _options.Suppress256ColumnsWarning = true;

                _options.Suppress65536RowsWarning = true;

                _options.TextExportMode = TextExportMode.Text;

                grid.ExportToXls(_saveFileDialog.FileName);

                DevMessageBoxHelper.ShowInfo(" Excel !");

            }

        }

        #endregion 

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

좋은 웹페이지 즐겨찾기