2010-03-13 3 views

답변

1

가장 쉬운 방법은 엑셀 ODBC 드라이버를 사용하는 아마. 이를 통해 OdbcConnection을 사용하여 워크 시트를 DataTable로 읽을 수 있습니다. 그런 다음 테이블의 행 모음을 반복하여 값을 목록이나 배열로 복사 할 수 있습니다.

+0

파일 작업 중 생각났습니다. 파일 행의 데이터를 읽습니다. 나는 .txt 파일 befor와 함께 일했으나 어떻게 사용했는지 잊어 버렸다. – LIX

+0

@LIX : 일반 텍스트 파일을 읽기가 비교적 쉽지만 Excel 파일 형식은 일반 텍스트가 아니며 특수한 독자가이를 읽어야합니다. –

+0

@itowlson : 질문과 지금 텍스트 발언을 볼 때, 그것은 사실에 대한 예시 일 수 있습니까? a) 예! 사회 공동체는 문화적으로 인식하고 커뮤니케이션 장애물을 없애기 위해 노력할 필요가있다. b) 영어가 가장 적게 요구되는 동료들에 의해 중단 되더라도, 좋고보기 흉한 질문은 그렇게 나쁘지 않다. c) 모두가 할 수는 없다. 도와 줘. 어떻게 생각해 ? 친절한 의견을 보내 주신 덕분에 – mjv

0

This link 당신을 도울 수 있습니다. 값을 정수로 변환 할 수 있습니다.

0

당신은 엑셀 Interop를 사용하고의 라인을 따라 뭔가를 할 수 있습니다

Excel.Range firstCell = excelWorksheet.get_Range("A1", Type.Missing); 
Excel.Range lastCell = excelWorksheet.get_Range("A10", Type.Missing); 
Excel.Range worksheetCells = excelWorksheet.get_Range(firstCell, lastCell); 
var cellValues = worksheetCells.Value2; 

당신은 객체 인덱스 (1)의 배열을 취득해야하고, 변환 (예를 들어)를 사용하여 내용을 캐스팅 할 수 있습니다. ToDouble().

0

SpreadsheetGear for .NET은 그것을 할 수 있습니다. 아래는 C# 소스입니다. SpreadsheetGear API는 Excel API와 유사하므로 아래 코드를 Excel에 적용 할 수 있습니다.

using System; 
using SpreadsheetGear; 

namespace Program 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      // Load a workbook from disk and get the first worksheet. 
      var workbook = SpreadsheetGear.Factory.GetWorkbook(@"C:\tmp\Numbers.xlsx"); 
      // Allocate a list of doubles to store the number. 
      var numbers = new System.Collections.Generic.List<double>(); 
      var worksheet = workbook.Worksheets[0]; 
      // Assuming that column A is the column with the numbers... 
      var columnA = worksheet.Cells["A:A"]; 
      var usedRange = worksheet.UsedRange; 
      // Limit the cells we look at to the used range of the sheet. 
      var numberCells = usedRange.Intersect(columnA); 
      // Get the numbers into the list. 
      foreach (IRange cell in numberCells) 
      { 
       object val = cell.Value; 
       if (val is double) 
        numbers.Add((double)val); 
      } 
      // Write the numbers to the console. 
      foreach (double number in numbers) 
       Console.WriteLine("number={0}", number); 
     } 
    } 
} 

당신이 그것을 자신을 시도하려는 경우 당신은 무료로하는 SpreadsheetGear 재판 here을 다운로드 할 수 있습니다.

면책 조항 : 소유권 SpreadsheetGear LLC

관련 문제