コード例 #1
0
 private void CustomizeSelectedItemsExporting(object sender, DataGridExcelExportingEventArgs e)
 {
     if (e.CellType == ExportCellType.RecordCell)
     {
         e.CellStyle.BackGroundColor = Color.Violet;
         e.Handled = true;
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: tzvis1/winforms-demos
        /// <summary>
        /// Occurs when the ExcelExportingOptions.Exporting event occurs.
        /// </summary>
        /// <param name="sender">The ExcelExportingOptions object.</param>
        /// <param name="e">The DataGridExcelExportingEventArgs that contains the event data.</param>
        private void OnExporting(object sender, DataGridExcelExportingEventArgs e)
        {
            if (e.CellType == ExportCellType.HeaderCell)
            {
                if (e.Level == 0)
                    e.CellStyle.BackGroundColor = Color.FromArgb(255, 155, 194, 230);
                else
                    e.CellStyle.BackGroundColor = Color.FromArgb(255, 146, 208, 80);

                e.CellStyle.ForeGroundColor = Color.White;
                e.CellStyle.FontInfo.Bold = true;
                e.Handled = true;
            }
        }
コード例 #3
0
 private void GridExcelExportingOptions_Exporting1(object sender, DataGridExcelExportingEventArgs e)
 {
     if (e.CellType == ExportCellType.HeaderCell)
     {
         e.CellStyle.FontInfo.Size     = (int)DpiAware.LogicalToDeviceUnits(12.0f);
         e.CellStyle.FontInfo.FontName = "Segoe UI";
         e.CellStyle.BackGroundColor   = Color.LightGray;
         e.CellStyle.ForeGroundColor   = Color.Black;
         e.CellStyle.FontInfo.Bold     = true;
         e.Handled = true;
     }
     else if (e.CellType == ExportCellType.GroupCaptionCell)
     {
         e.CellStyle.FontInfo.Size     = (int)DpiAware.LogicalToDeviceUnits(12.0f);
         e.CellStyle.FontInfo.FontName = "Segoe UI";
         e.CellStyle.FontInfo.Bold     = true;
         e.CellStyle.BackGroundColor   = Color.LightSeaGreen;
         e.CellStyle.ForeGroundColor   = Color.Black;
         e.Handled = true;
     }
 }