标签:style blog color strong os cti
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开发:单元格区域的操作(读取、赋值、边框和格式),布布扣,bubuko.com
基于.NET的Excel开发:单元格区域的操作(读取、赋值、边框和格式)
标签:style blog color strong os cti
原文地址:http://www.cnblogs.com/liusuqi/p/3819874.html