using Excel = Microsoft.Office.Interop.Excel;
1 Excel.applicationclass app; 2 excel.workbooks Books; 3 Excel.Workbook Book; 4 excel.sheets Sheets; 5 Excel.Worksheet sheet; 6 Excel.Range m_objrange; 7 object missing = System.Reflection.Missing.Value;
- Read valid range of cells
1 foreach(Excel.Worksheet sheetinchBook . Sheets)2 {3 for(inti =1; I <= sheet. UsedRange.Cells.Rows.Count; i++)4 {5 for(intj =1; J <= Sheet. UsedRange.Cells.Columns.Count; J + +)6 {7Excel.Range m_objrange =(excel.range) sheet. Cells[i, j];8 }9 }Ten}
1 m_objrange = sheet. Get_range (the value of the"A1"2" cell ");
- Cell range Settings Excel formula
1 m_objrange = sheet. Get_range ("A1"2"=sum (A2: A5)");
1 true;
1 // Keep 2 decimal places 2 " 0.00 ";
1 m_objrange = sheet. Get_range ( " A1 ", " b2 " ); 2 // set border weight 3 m_objRange.Borders.Weight = 2 ; 4 // set border style 5 M_objRange.Borders.get_Item ( EXCEL.XLBORDERSINDEX.XLEDGETOP). LineStyle = Excel.XlLineStyle.xlDouble;
Xlcontinuous: Solid line.
Xldash: Dashed line. Xldashdot: Point and Cross Line. Xldashdotdot: Dash followed by two points. Xldot: Dot line. Xldouble: Double line. Xllinestylenone: No lines.
Xlslantdashdot: Slanted Dash.
- XlBordersIndex Enumeration
Xldiagonaldown: Diagonal, from upper left corner to bottom right corner. Xldiagonalup: Diagonal, from upper left corner to bottom right corner. Xledgebottom: Bottom Border. Xledgeleft: Left border.
Xledgeright: Right border.
Xledgetop: Top Border. Xlinsidehorizontal: Internal horizontal border. Xlinsidevertical Vertical: Internal vertical border.
The
is based on. NET Excel Development: operation of a cell range (read, assign, border, and format)