2009-03-10 4 views

답변

1

thro '5000 레코드를 검색하려고하므로'thro '값을 검색하려고 시도해야한다고 가정합니다. Interop API의 "Range.Find"를 사용하여이를 수행 할 수 있습니다.

private void OpenExcelFile() 
{ 
    Excel.Application exlApp = new Microsoft.Office.Interop.Excel.Application(); 

    if (exlApp == null) 
    { 
     MessageBox.Show("Excel app object could not be created"); 
    } 
    else 
    { 

     exlFileSelector.FileName = @"*.xls"; 

     if (exlFileSelector.ShowDialog() == DialogResult.OK) 
     { 
      Excel.Workbook wrkBook = exlApp.Workbooks.Open(exlFileSelector.FileName, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, true, true); 
      Excel.Sheets sheetList = wrkBook.Sheets; 

      Excel.Range search = exlApp.get_Range("A1", "C5"); 
      search.Find("FindMe", null, Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, false, null, null); 
     } 
    } 
} 

추가 읽기 : How to: Search for Text in Worksheet Ranges

0

값은 스프레드 시트의 공식 중 하나 또는 실제 값으로 계산 된 계산 값입니까? 그것은 이상이 있다면

, 당신은 XML과 같은 스프레드 시트를 저장하고 적절하게 사용 가능한이 인덱싱 기술에 따라
또는
, 당신은 그들이 다음 색인을 검색 색인을 할 수 있습니다를 분석하고 적절한 값을 찾을 수 .

전의 경우, 내가 생각할 수있는 유일한 방법은 InterOp 라이브러리를 사용하여 각각을 열고 API를 사용하는 것입니다.

+0

문자열 값입니다. – Dhana

+0

검색을 단순화시켜야하며 인덱싱 솔루션이 적절할 수 있습니까? – Bravax

1

SpreadsheetGear for .NET는 Excel의 찾기 API와 유사한 찾기 API를 지원 .NET 용 엑셀 호환 스프레드 시트 구성 요소입니다. 값 또는 수식을 검색하거나 수식을 계산 한 다음 필요에 따라 결과를 검색 할 수 있습니다.

// Open an xlsx workbook (can also open xls). 
IWorkbook workbook = Factory.GetWorkbook(@"C:\tmp\Data.xlsx"); 

// Find the first cell which starts with "John". 
IRange foundCell = workbook.Worksheets["Sheet1"].Cells.Find("John*", null, 
    FindLookIn.Values, LookAt.Whole, SearchOrder.ByColumns, SearchDirection.Next, true); 
if (foundCell != null) 
    Console.WriteLine("found {0} in cell {1}", foundCell.Text, foundCell.Address); 

당신은 무료 평가 here을 다운로드 할 수 있습니다 여기에 통합 문서를로드하고 최초의 "요"로 시작 셀을 찾아 간단한 샘플입니다.

면책 조항 : 소유권이 SpreadsheetGear LLC

관련 문제