标签:missing mod height track 小数 ash log xls dash
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;
1 foreach (Excel.Worksheet sheet in book.Sheets) 2 { 3 for (int i = 1; i <= sheet.UsedRange.Cells.Rows.Count; i++) 4 { 5 for (int j = 1; j <= sheet.UsedRange.Cells.Columns.Count; j++) 6 { 7 Excel.Range m_objRange = (Excel.Range)sheet.Cells[i, j]; 8 } 9 } 10 }
1 m_objRange = sheet .get_Range("A1",missing ); 2 m_objRange.set_Value(missing , "单元格的值");
1 m_objRange = sheet .get_Range("A1", missing ); 2 m_objRange.set_Value(missing , "=SUM(A2:A5)");
1 m_objRange.Font.Bold = true;
1 //保留2位小数 2 m_objRange.NumberFormat = "0.00";
1 m_objRange = sheet .get_Range("A1", "B2"); 2 //设置边框粗细 3 m_objRange.Borders.Weight = 2; 4 //设置边框样式 5 m_objRange.Borders.get_Item(Excel.XlBordersIndex.xlEdgeTop).LineStyle = Excel.XlLineStyle.xlDouble;
基于.NET的Excel开发:单元格区域的操作(读取、赋值、边框和格式)
标签:missing mod height track 小数 ash log xls dash
原文地址:http://www.cnblogs.com/lytwajue/p/6962014.html