2013-01-15 2 views
0

지금 당장은 내 프로그래밍 능력을 높이려고 노력하므로 도움이 될 것입니다. 내가 사용했던 내 asp.net 프로젝트에서엑셀 문서 가져 오기, 적절한 형식의 디스플레이

(영문)

<asp:Panel ID="Excel" runat="server">  
</asp:Panel> 

(aspx.cs)

ExcelFile ef = new ExcelFile(); 
     string fileName = @"C:\\location of excel doc"; 
     ef.LoadXlsx(fileName, XlsxOptions.PreserveMakeCopy); 

     StringBuilder sb = new StringBuilder(); 

     foreach (ExcelWorksheet sheet in ef.Worksheets) 
     { 
      sb.AppendLine(); 
      sb.AppendFormat("------{0}--------", sheet.Name); 

      foreach (ExcelRow row in sheet.Rows) 
      { 
       sb.AppendLine(); 
       foreach (ExcelCell cell in row.AllocatedCells) 
       { 
        if (cell.Value != null) 
        { 
         Label x = new Label(); 
         x.Text = cell.Value.ToString(); 
         Excel.Controls.Add(x); 

         sb.AppendFormat("{0}({1})", cell.Value, cell.Value.GetType().Name); 
         sb.Append("\t"); 
        } 
       } 
      } 
     } 

     Console.WriteLine(sb.ToString()); 

이 잘 작동하지만의 큰 덩어리로 Excel 파일을 표시합니다 텍스트가 뭉치면 누군가가 팁을 주거나 어딘가에서 멋진 테이블에 출력을 표시하는 방법을 시작하면 감사하겠습니다.

답변

1

엑셀 시트에서 가져온 데이터를 표시하려면 GridView 컨트롤을 사용해야합니다.

+0

제발 저에게 examaple을 주시겠습니까? – John