Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

How to iterate through a column in an Excel application through C# Console? -


i have created console application reads excel file. want take of document numbers , place in array searching purposes. able find cell contains data "documentnumber" e.g. $f$5. how can iterate through rows within column f? have following code:

public static void main(string[] args)     {         string address;         string next;         try         {             excel.applicationclass excel = new excel.applicationclass();             excel.workbook workbook = excel.workbooks.open(@"d:\sample.xls", missing.value, missing.value,                 missing.value, missing.value, missing.value, missing.value, missing.value,                 missing.value, missing.value, missing.value, missing.value, missing.value,                 missing.value, missing.value);             excel.worksheet worksheet = (excel.worksheet)workbook.sheets["sheet1"];             excel.range docnumber = worksheet.cells.find("documentnumber", worksheet.cells[1, 1], excel.xlfindlookin.xlvalues,                 excel.xllookat.xlpart, missing.value, excel.xlsearchdirection.xlnext,                 false, missing.value, missing.value);              if(docnumber != null){                 address = docnumber.get_address(true, true, excel.xlreferencestyle.xla1, missing.value, missing.value);                 console.writeline(address);              }         }         catch (exception err)         {             console.writeline(err.message);         }     } 

thanks in advance.

kindly this.it iterates through each , every rows , columns.

string address;   string next;   try {       excel.applicationclass excel = new excel.applicationclass();     object missing = type.missing;     fileinfo finfo = new fileinfo(@"d:\sample.xls");      if(finfo.exists) {         excel.workbook workbook = excel.workbooks.open(@"d:\sample.xls", missing, missing,                      missing, missing, missing, missing, missing,                       missing, missing, missing, missing, missing,                       missing, missing);               excel.worksheet worksheet = (excel.worksheet)workbook.sheets["sheet1"];         excel.range docnumber = worksheet.cells.find("ddec", worksheet.cells[1, 1],          excel.xlfindlookin.xlvalues, excel.xllookat.xlpart, missing, excel.xlsearchdirection.xlnext, false, missing, missing);               if(docnumber != null) {             address = docnumber.get_address(true, true, excel.xlreferencestyle.xla1, missing, missing);             docnumber = worksheet.usedrange;                                      (int rcnt = 1; rcnt <= docnumber.rows.count; rcnt++) {                 (int ccnt = 1; ccnt <= docnumber.columns.count; ccnt++) {                     string str = (string)(docnumber.cells[rcnt, ccnt] excel.range).value2;                     messagebox.show(str);                 }             }             console.writeline(address);          }          } } 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -