private _Workbook _workBook = null;
private Worksheet _workSheet = null;
private Excel.Application _excelApplicatin = null;
_excelApplicatin = new Excel.Application();
_excelApplicatin.Visible = true;
_excelApplicatin.DisplayAlerts = true;
_workBook = _excelApplicatin.Workbooks.Add(XlSheetType.xlWorksheet);
_workSheet = (Worksheet)_workBook.ActiveSheet;
_workSheet.Name = "workSheetName";
//打开已存在的Excel
string strExcelPathName = AppDomain.CurrentDomain.BaseDirectory + "excelSheetName.xls";
Excel.Workbook workBook = application.Workbooks.Open(strExcelPathName, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
//读取已打开的Excel
Excel.Worksheet workSheet1 = (Excel.Worksheet)workBook.Sheets["SheetName1"];
Excel.Worksheet workSheet2 = (Excel.Worksheet)workBook.Sheets["SheetName2"];
//添加一个workSheet
Worksheet workSheet = (Worksheet)workBook.Worksheets.Add(System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);
//RowHeight "1:1"表示第一行, "1:2"表示,第一行和第二行
((Excel.Range)_workSheet.Rows["1:1", System.Type.Missing]).RowHeight = 100;
//ColumnWidth "A:B"表示第一列和第二列, "A:A"表示第一列
((Excel.Range)_workSheet.Columns["A:B", System.Type.Missing]).ColumnWidth = 10;
// EXCEL操作(需要冻结的字段 按住ALT+W 再按F)
Excel.Range excelRange = _workSheet .get_Range(_workSheet .Cells[10, 5], _workSheet .Cells[10, 5]);
excelRange.Select();
excelApplication.ActiveWindow.FreezePanes = true;
//Borders.LineStyle 单元格边框线
Excel.Range excelRange = _work
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn
为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
|