reading data from exxcel
-
I have run the program given below but iam not getting the values from excel can anyone help me out in this plz using System; using Excel; namespace TestExcel { /// /// Summary description for ExcelApplication. /// class ExcelApplication { /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { string Path = @"D:\book1.xls"; // initialize the Excel Application class Excel.ApplicationClass app = new ApplicationClass(); // create the workbook object by opening the excel file. Excel.Workbook workBook = app.Workbooks.Open(Path, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); // get the active worksheet using sheet name or active sheet Excel.Worksheet workSheet = (Excel.Worksheet)workBook.ActiveSheet; string[] name = {"SPACE_REF","LOCAL_SPACE_NAME","SPACE_AREA","SPACE_USE","CAT_CODE","SUB_CAT_CODE","SCHOOL_USE", "NIA","EXCLUDED_%","SUFFICIENCY_SPACE_TYPE","SUFFICIENCY_STAUS_CODE","CEILING_HEIGHT","CEILING_TYPE", "FLOOR_TYPE","CLN_SPEC","CLN_BY","FLOOR_REF","BUILDING_REF","SHARED_SPACE","SHARED_REF","SI_SKETCH_NO", "UPRN","LMS%"}; int l; l = name.Length; for (int a =1; a
-
I have run the program given below but iam not getting the values from excel can anyone help me out in this plz using System; using Excel; namespace TestExcel { /// /// Summary description for ExcelApplication. /// class ExcelApplication { /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { string Path = @"D:\book1.xls"; // initialize the Excel Application class Excel.ApplicationClass app = new ApplicationClass(); // create the workbook object by opening the excel file. Excel.Workbook workBook = app.Workbooks.Open(Path, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); // get the active worksheet using sheet name or active sheet Excel.Worksheet workSheet = (Excel.Worksheet)workBook.ActiveSheet; string[] name = {"SPACE_REF","LOCAL_SPACE_NAME","SPACE_AREA","SPACE_USE","CAT_CODE","SUB_CAT_CODE","SCHOOL_USE", "NIA","EXCLUDED_%","SUFFICIENCY_SPACE_TYPE","SUFFICIENCY_STAUS_CODE","CEILING_HEIGHT","CEILING_TYPE", "FLOOR_TYPE","CLN_SPEC","CLN_BY","FLOOR_REF","BUILDING_REF","SHARED_SPACE","SHARED_REF","SI_SKETCH_NO", "UPRN","LMS%"}; int l; l = name.Length; for (int a =1; a
I'm not an expert at the Excel stuff but two things that stick out at me are a) inside the while loop workSheet.Cells is being indexed with 1,1 for every iteration of the loop instead of i and j b) also inside the loop the call to console.writeline is printing spaces, the string should be "{0}" maybe that'll help . . .