Excel.Workbook workBook = app.Workbooks.Open(templetFile,missing,missing,missing,missing,missing,
missing,missing,missing,missing,missing,missing,missing);错误 1 “Open”方法没有采用“13”个参数的重载
1using System;
2using System.IO;
3using System.Data;
4using System.Reflection;
5using System.Diagnostics;
6using cfg = System.Configuration;
7//using Excel;
8
9namespace ExcelHelperTest
10{
11 /**//// <summary>
12 /// 功能说明:套用模板输出Excel,并对数据进行分页
13 /// 作 者:Lingyun_k
14 /// 创建日期:2005-7-12
15 /// </summary>
16 public class ExcelHelper
17 {
18 protected string templetFile = null;
19 protected string outputFile = null;
20 protected object missing = Missing.Value;
21
22 /**//// <summary>
23 /// 构造函数,需指定模板文件和输出文件完整路径
24 /// </summary>
25 /// <param name="templetFilePath">Excel模板文件路径</param>
26 /// <param name="outputFilePath">输出Excel文件路径</param>
27 public ExcelHelper(string templetFilePath,string outputFilePath)
28 {
29 if(templetFilePath == null)
30 throw new Exception("Excel模板文件路径不能为空!");
31
32 if(outputFilePath == null)
33 throw new Exception("输出Excel文件路径不能为空!");
34
35 if(!File.Exists(templetFilePath))
36 throw new Exception("指定路径的Excel模板文件不存在!");
37
38 this.templetFile = templetFilePath;
39 this.outputFile = outputFilePath;
40
41 }
42
43 /**//// <summary>
44 /// 将DataTable数据写入Excel文件(套用模板并分页)
45 /// </summary>
46 /// <param name="dt">DataTable</param>
47 /// <param name="rows">每个WorkSheet写入多少行数据</param>
48 /// <param name="top">行索引</param>
49 /// <param name="left">列索引</param>
50 /// <param name="sheetPrefixName">WorkSheet前缀名,比如:前缀名为“Sheet”,那么WorkSheet名称依次为“Sheet-1,Sheet-2”</param>
51 public void DataTableToExcel(DataTable dt,int rows,int top,int left,string sheetPrefixName)
52 {
53 int rowCount = dt.Rows.Count; //源DataTable行数
54 int colCount = dt.Columns.Count; //源DataTable列数
55 int sheetCount = this.GetSheetCount(rowCount,rows); //WorkSheet个数
56 DateTime beforeTime;
57 DateTime afterTime;
58
59 if(sheetPrefixName == null || sheetPrefixName.Trim() == "")
60 sheetPrefixName = "Sheet";
61
62 //创建一个Application对象并使其可见
63 beforeTime = DateTime.Now;
64 Excel.Application app = new Excel.ApplicationClass();
65 app.Visible = true;
66 afterTime = DateTime.Now;
67
68 //打开模板文件,得到WorkBook对象
69 Excel.Workbook workBook = app.Workbooks.Open(templetFile,missing,missing,missing,missing,missing,
missing,missing,missing,missing,missing,missing,missing);
missing,missing,missing,missing,missing,missing,missing);错误 1 “Open”方法没有采用“13”个参数的重载
1using System;
2using System.IO;
3using System.Data;
4using System.Reflection;
5using System.Diagnostics;
6using cfg = System.Configuration;
7//using Excel;
8
9namespace ExcelHelperTest
10{
11 /**//// <summary>
12 /// 功能说明:套用模板输出Excel,并对数据进行分页
13 /// 作 者:Lingyun_k
14 /// 创建日期:2005-7-12
15 /// </summary>
16 public class ExcelHelper
17 {
18 protected string templetFile = null;
19 protected string outputFile = null;
20 protected object missing = Missing.Value;
21
22 /**//// <summary>
23 /// 构造函数,需指定模板文件和输出文件完整路径
24 /// </summary>
25 /// <param name="templetFilePath">Excel模板文件路径</param>
26 /// <param name="outputFilePath">输出Excel文件路径</param>
27 public ExcelHelper(string templetFilePath,string outputFilePath)
28 {
29 if(templetFilePath == null)
30 throw new Exception("Excel模板文件路径不能为空!");
31
32 if(outputFilePath == null)
33 throw new Exception("输出Excel文件路径不能为空!");
34
35 if(!File.Exists(templetFilePath))
36 throw new Exception("指定路径的Excel模板文件不存在!");
37
38 this.templetFile = templetFilePath;
39 this.outputFile = outputFilePath;
40
41 }
42
43 /**//// <summary>
44 /// 将DataTable数据写入Excel文件(套用模板并分页)
45 /// </summary>
46 /// <param name="dt">DataTable</param>
47 /// <param name="rows">每个WorkSheet写入多少行数据</param>
48 /// <param name="top">行索引</param>
49 /// <param name="left">列索引</param>
50 /// <param name="sheetPrefixName">WorkSheet前缀名,比如:前缀名为“Sheet”,那么WorkSheet名称依次为“Sheet-1,Sheet-2”</param>
51 public void DataTableToExcel(DataTable dt,int rows,int top,int left,string sheetPrefixName)
52 {
53 int rowCount = dt.Rows.Count; //源DataTable行数
54 int colCount = dt.Columns.Count; //源DataTable列数
55 int sheetCount = this.GetSheetCount(rowCount,rows); //WorkSheet个数
56 DateTime beforeTime;
57 DateTime afterTime;
58
59 if(sheetPrefixName == null || sheetPrefixName.Trim() == "")
60 sheetPrefixName = "Sheet";
61
62 //创建一个Application对象并使其可见
63 beforeTime = DateTime.Now;
64 Excel.Application app = new Excel.ApplicationClass();
65 app.Visible = true;
66 afterTime = DateTime.Now;
67
68 //打开模板文件,得到WorkBook对象
69 Excel.Workbook workBook = app.Workbooks.Open(templetFile,missing,missing,missing,missing,missing,
missing,missing,missing,missing,missing,missing,missing);
解决方案 »
- 求一条 SQL 语句
- “事件”的疑问
- 大家是如何做每个页面的用户验证的?
- 关于自定义的DataGrid
- 如何使vs.net写的页面通过w3的web标准验证??
- 请问<span>中有滚动条,javascript中当拖动滚动条时有onscroll事件响应吗?
- ExecuteNonQuery执行存储过程的返回值是什么?
- 在一个框架中的有两个窗体A,B,如何在A中的按钮事件中,使B窗体导向另外一个窗体C?
- asp.net打包全过程
- 大家来帮忙测试一下这个ASPX+xml的论坛
- [紧急,在线等待]在javascript中把url参数加密,在.net的.cs里面怎么解密码?
- ICallbackEventHandler 实现 gridview刷新,如果数据有中文就出现乱码,用utf8转过都没有用,盼高手帮忙!
2003好像是15个参数的
出现:DataTable”是“System.Data.DataTable”和“Excel.DataTable”之间的不明确的引用
搞EXCEL报表已经用了我两个星期的时间了```
再不搞好就要给骂了
missing,missing,missing,missing,missing,missing,missing,missing,missing);