office操作笔记:c#与excel之helloword
2017-06-02 01:01
435 查看
作为微软自己开发的语言c#和自己家的软件的交互真是太简单了。
例子很简单,APPlication实例化、添加工作簿、操纵工作簿、保存退出。
例子很简单,APPlication实例化、添加工作簿、操纵工作簿、保存退出。
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Office.Interop.Excel; namespace excel { class Program { static void Main(string[] args){ Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); if (xlApp == null) { Console.Error.WriteLine("excel is not properly installed!"); } Workbook xlWorkBook = xlApp.Workbooks.Add(System.Reflection.Missing.Value); Worksheet xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1); xlWorkSheet.Cells[1, 1] = "ID"; xlWorkSheet.Cells[1, 2] = "Name"; xlWorkSheet.Cells[2, 1] = "1"; xlWorkSheet.Cells[2, 2] = "One"; xlWorkSheet.Cells[3, 1] = "2"; xlWorkSheet.Cells[3, 2] = "Two"; xlWorkBook.SaveAs("mm.xlsx"); xlWorkBook.Close(true, "mm.xlsx", System.Reflection.Missing.Value); xlApp.Quit(); } } }
相关文章推荐
- C#操作office组件(excel、word、ppt)报错问题!
- C# 操作office(word、excel)com异常问题
- C#的office操作[word&Excel]
- C#操作Excel,调用ApplicationClass.Quit()关闭Excel时,发生异常:Microsoft Office Word 遇到问题需要关闭
- C#操作Word和Excel笔记
- C#的office操作[word&Excel]
- C#操作office方面的总结 Excel和Word
- C# OFFICE WORD EXCEL操作
- C#操作office方面的总结 Excel和Word
- C#操作office方面的总结 Excel和Word
- C#操作office方面的总结 Excel和Word
- C#操作office进行Excel图表创建,保存本地,word获取
- C#的office操作[word&Excel]
- C#的office操作[word&Excel]
- C#操作office进行Excel图表创建,保存本地,word获取
- C#的Office操作(Word&Excel)
- 关于C#操作EXCEL,生成图表的全面应用之一(利用Microsoft.Office.Interop.Excel)
- 在应用程序上实现OFFICE相关的WORD EXCEL导入导出操作
- C# 操作 Excel 与 C#操作 word 示例大全
- Web服务中调用office pia 操作WORD,EXCEL时需做的设置