2016-06-14 2 views
0

Excel 표를 HTML 표로 가져와 어떻게 모든 행을 열 이름을 기준으로 객체로 변환 할 수 있습니까? 각도 JS 사용Excel 시트에서 AngularJS를 사용하여 HTML 표로 표 가져 오기

추신 : 향후 정렬 된 테이블에는 개체가 필요합니다.

+0

당신은 어떤 대답을 여기에서 찾을 수 있습니다 : http://stackoverflow.com/questions/18450259/paste-into-nggrid- from-excel 및 여기 : http://stackoverflow.com/questions/30765389/angularjs-ui-grid-import-xlsx-data-best-approach – Mistalis

답변

1

저는이를위한 구성 요소를 개발했습니다. 당신을 도움이되는지를 살펴 주시기 바랍니다 : 당신에게 파일을 선택할 수있는 능력을 제공합니다

<input type="file" xlsx-model="excel"> 

를 사용 https://github.com/Helvio88/angular-xlsx-model

. 여러 파일의 경우
은 :

<input type="file" xlsx-model="excel" multiple> 

더 나아가 등 특정 확장과를 필터링 할 수 있도록 확장 할 수 있습니다. (

$의 scope.excel 여러 파일을 : 당신이 (이 경우 '엑셀'에서) 파일의 XLSX 모델 속성의 이름을 딴 각도 JSON 객체를 선택하면이 형식으로 작성됩니다 http://www.w3schools.com/jsref/dom_obj_fileupload.asp

참조) :

{ 
    "file1.xlsx": { 
     "Sheet1": [ 
      { 
       "Col1Name": "Row1Col1_Value", 
       "Col2Name": "Row1Col2_Value" 
      }, 
      { 
       "Col1Name": "Row2Col1_Value", 
       "Col2Name": "Row2Col2_Value" 
      } 
     ], 
     "Sheet2" : [...] 
    }, 
    "file2.xlsx": {...} 
} 

여러 파일을 선택한 경우 해당 모델이 유효합니다. 단일 파일의 경우 약간 다릅니다.
$의 scope.excel (단일 파일) :

{ 
    "Sheet1": [ 
     { 
      "Col1Name": "Row1Col1_Value", 
      "Col2Name": "Row1Col2_Value" 
     }, 
     { 
      "Col1Name": "Row2Col1_Value", 
      "Col2Name": "Row2Col2_Value" 
     } 
    ], 
    "Sheet2" : [...] 
} 

놀이터 : http://plnkr.co/edit/inETA0PcxIkm4EmS9qjD?p=preview

관련 문제