2016-10-07 2 views
2

ASP.NET 프로젝트에서 DevExpress의 dxDataGrid을 사용하여 SQL Server 데이터베이스에 저장된 일부 데이터를 표시합니다.dxDataGrid 컨트롤에 배경색 적용 및 Excel로 내보내기

Results from dxDataGrdi control

하지만, I를 :

// Variables. 
var vlrMin = [];  
var vlrMax = [];  
var vlr_to_match = 0; 
var colors = [];  
var final_rst = ""; 

// Add values to variables: 
vlrMin.push("9"); 
vlrMin.push("2"); 
vlrMin.push("9"); 

// Add values to variables: 
vlrMax.push("13"); 
vlrMax.push("7"); 
vlrMax.push("4"); 

colors.push('#ff0000'); 
colors.push('#92D050'); 
colors.push('#5B9BD5'); 

// Start configuration. 
$("#gridContainer").dxDataGrid({ 
    dataSource: [{ 
     "Dept": "Local services", 
     "Employee": "John Doe", 
     "TotalHours": "11" 
    }], 
    paging: { 
     pageSize: 10 
    }, 
    export: { 
     allowExportSelectedData: true, 
     enabled: true, 
     fileName: 'Reporte 1', 
     texts: { 
      exportAll: 'Export all', 
      exportSelectedRows: 'Export selected row(s).', 
      exportTo: 'Export' 
     }, 
    }, 
    searchPanel: { 
     visible: true 
    }, 
    filterRow: { 
     visible: true, 
     showOperationChooser: true 
    }, 
    allowColumnReordering: true, 
    grouping: { 
     autoExpandAll: true 
    }, 
    groupPanel: { 
     visible: true 
    }, 
    pager: { 
     showPageSizeSelector: true, 
     allowedPageSizes: [5, 10, 20], 
     showInfo: true 
    }, 
    columns: ['Dept', 
     'Employee', { 
      dataField: 'TotalHours', 
      allowFiltering: true, 
      allowSorting: true, 
      cellTemplate: function(container, options) { 
       /* Value to check if matches with the criteria. */ 
       var vlr_to_match = options.value; 

       /* Loop elements. */ 
       for (var mn = 0; mn < vlrMin.length; mn++) { 
        if (vlr_to_match >= vlrMin[mn] && vlr_to_match <= vlrMax[mn]) { 
         final_rst = colors[mn]; 
         break; 
        } 
       } 

       /* Apply custom style to element. */ 
       $('<span>').text(options.data.TotalHours) 
        .attr('style', 'background-color: ' + final_rst) 
        .appendTo(container); 
      } 
     } 
    ] 
}); 

이것은 dxDataGrid 제어의 결과입니다 : 데이터를 렌더링을 위해 내가 dxDataGrid 컨트롤을하고 있어요 방법

다음 코드는 보여줍니다 "DevExpress 기능을 사용하여"생성 된 파일을 엽니 다. 스크린 샷에 표시된 것과 같은 결과가 나타나지 않습니다. (즉 셀에 값이 있지만 스타일이 적용되지 않습니다. d).

documentation

에 따르면, 상기 제어 dxDataGrid에 도시 된 바와 같이 보낸 엑셀 파일이 열릴 dxDataGrid 제어에 apply a color to an specific cell 후, 셀은 동일한 결과를 얻지 못하고있다.

내 질문은 :

  • 어떻게 파일을 생성 된 Excel로 같은 결과를 dxDataGrid 셀에 스타일을 적용하고 적용 할 수 있는가?

답변

0

불행히도, 지원 포럼의 DX 항목에 대한 최근의 답변 (2016-09-20)을 토대로 dxDataGrid를 포맷팅으로 내보내는 데는 DevExtreme 소송에서 방법이 없습니다.

자신을 참조하십시오 : https://www.devexpress.com/Support/Center/Question/Details/T429240

당신이 ASPxGridViewExporter와 함께 DevEpress ASPxGridView 제어를 사용한 경우는 셀 당 또는 행 당 보낸 엑셀 문서의 형식을 사용자 정의 할 수있을 것입니다.