C# Winform里面输出数据到Excel的问题
来源:互联网 发布:中国保险网络大学网址 编辑:程序博客网 时间:2024/05/01 19:20
using System;
using System.Reflection;
using Microsoft.Office.Interop.Excel;
public class CreateExcelWorksheet
{
static void Main()
{
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
if (xlApp == null)
{
Console.WriteLine("EXCEL could not be started. Check that your office installation and project references are correct.");
return;
}
xlApp.Visible = true;
Workbook wb = xlApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
Worksheet ws = (Worksheet)wb.Worksheets[1];
if (ws == null)
{
Console.WriteLine("Worksheet could not be created. Check that your office installation and project references are correct.");
}
// Select the Excel cells, in the range c1 to c7 in the worksheet.
Range aRange = ws.get_Range("C1", "C7");
if (aRange == null)
{
Console.WriteLine("Could not get a range. Check to be sure you have the correct versions of the office DLLs.");
}
// Fill the cells in the C1 to C7 range of the worksheet with the number 6.
Object[] args = new Object[1];
args[0] = 6;
aRange.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, aRange, args);
// Change the cells in the C1 to C7 range of the worksheet to the number 8.
aRange.Value2 = 8;
}
}
using System.Reflection;
using Microsoft.Office.Interop.Excel;
public class CreateExcelWorksheet
{
static void Main()
{
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
if (xlApp == null)
{
Console.WriteLine("EXCEL could not be started. Check that your office installation and project references are correct.");
return;
}
xlApp.Visible = true;
Workbook wb = xlApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
Worksheet ws = (Worksheet)wb.Worksheets[1];
if (ws == null)
{
Console.WriteLine("Worksheet could not be created. Check that your office installation and project references are correct.");
}
// Select the Excel cells, in the range c1 to c7 in the worksheet.
Range aRange = ws.get_Range("C1", "C7");
if (aRange == null)
{
Console.WriteLine("Could not get a range. Check to be sure you have the correct versions of the office DLLs.");
}
// Fill the cells in the C1 to C7 range of the worksheet with the number 6.
Object[] args = new Object[1];
args[0] = 6;
aRange.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, aRange, args);
// Change the cells in the C1 to C7 range of the worksheet to the number 8.
aRange.Value2 = 8;
}
}
- C# Winform里面输出数据到Excel的问题
- Winform中Datagird数据输出到Excel表格,C# .NET
- C#输出数据到Excel
- C# Winform中导出数据到Excel
- 将GrideView里面的数据输出Excel
- C#输出DataTable数据到Excel文件
- c# winform 中导入Excel 的问题 !
- c#将datagridview中的数据导入到Excel中(winForm)
- python-把excel里面的数据存储到矩阵里面
- C#输出到Excel
- 用C#输出数据到excel的最简单的例子--and--C#如何退出excel的进程!
- 用C#输出数据到excel的最简单的例子(By kiseigo)
- c# 导出excel 填充数据 输出到浏览器
- 把WinForm的DataGridView的数据导出到Excel
- java swing 导出Jtable里面的数据到excel
- 如何将form里面的数据导出到excel中
- 怎样把 excel 的数据导入到数据库里面去
- 将数据库里面的数据导入到Excel(Java)
- 【看“赢在中国”】聪明的人VS智慧的人
- 成功将EIE升级为SQLSERVER2005
- 浏览器状态码的含义
- 访李会军:程序员的床头应当放哪两本书
- Apache SOAP在 tomcat下安装
- C# Winform里面输出数据到Excel的问题
- SOAP编程起步
- ireport+jasperReport画报表
- “Visual Studio .NET 无法创建或打开应用程序
- 昨夜清风来入梦
- Active Directory服务和Windows 2000或Windows Server 2003域
- Asp.net总调用的3个事件
- xcopy命令用法
- JAVA如何获得日期以及时间