Excel.Workbook theWorkbook=Class读取数据库_ds.LoadExecl(@"D:\Documents and Settings\user\My Documents\新建文件夹 周勇\工作文档\选区选民登记表\选区选民登记表.xls");
Excel.Sheets sheets=theWorkbook.Worksheets;
Excel.Worksheet thesheet=(Excel.Worksheet)sheets.get_Item(1);
int cols=thesheet.Columns.Count;
int rows=thesheet.Rows.Count;
int nowcols=thesheet.get_Range("A1","A1").CurrentRegion.Columns.Count;
int nowrows=thesheet.get_Range("A1","A1").CurrentRegion.Rows.Count;
Excel.Range range=thesheet.get_Range(thesheet.Cells[1,1],thesheet.Cells[nowrows,nowcols]);
System.Array myvalues=(System.Array)range.Cells.Value;
// myvalues.GetValue(i,1)
Lds.连接字符串=Con_st1;
DataTable dtz1=Lds.LoadData("员工情况","员工情况","","","二级行=78 OR 二级行=66");
int i=5;
基本表信息库 this信息库民族=new 基本表信息库(系统库2,"民族索引");
foreach(DataRow myRow in dtz1.Rows)
{
thesheet.Cells[i,1]=i-4;
thesheet.Cells[i,2]=myRow["姓名"];
thesheet.Cells[i,3]=myRow["性别"];
thesheet.Cells[i,4]=myRow["出生日期"];
thesheet.Cells[i,5]=this信息库2.快读库内名称值("民族",myRow["民族"],"");
thesheet.Cells[i,6]=this信息库2.快读库内名称值("政治面貌",myRow["政治面貌"],"");
thesheet.Cells[i,7]=this信息库2.快读库内名称值("二级行",myRow["二级行"],"");
thesheet.Cells[i,9]=myRow["员工编号"].ToString().PadLeft(5,'0'); // range.Cells[i,1]=myRow["姓名"];
// myvalues.SetValue(myRow["姓名"],i,1);
// string s1=myvalues.GetValue(i,1).ToString();
i++;
}
theWorkbook.Save();
theWorkbook.Close(这里有3个参数,不知道怎么填);
Excel.Sheets sheets=theWorkbook.Worksheets;
Excel.Worksheet thesheet=(Excel.Worksheet)sheets.get_Item(1);
int cols=thesheet.Columns.Count;
int rows=thesheet.Rows.Count;
int nowcols=thesheet.get_Range("A1","A1").CurrentRegion.Columns.Count;
int nowrows=thesheet.get_Range("A1","A1").CurrentRegion.Rows.Count;
Excel.Range range=thesheet.get_Range(thesheet.Cells[1,1],thesheet.Cells[nowrows,nowcols]);
System.Array myvalues=(System.Array)range.Cells.Value;
// myvalues.GetValue(i,1)
Lds.连接字符串=Con_st1;
DataTable dtz1=Lds.LoadData("员工情况","员工情况","","","二级行=78 OR 二级行=66");
int i=5;
基本表信息库 this信息库民族=new 基本表信息库(系统库2,"民族索引");
foreach(DataRow myRow in dtz1.Rows)
{
thesheet.Cells[i,1]=i-4;
thesheet.Cells[i,2]=myRow["姓名"];
thesheet.Cells[i,3]=myRow["性别"];
thesheet.Cells[i,4]=myRow["出生日期"];
thesheet.Cells[i,5]=this信息库2.快读库内名称值("民族",myRow["民族"],"");
thesheet.Cells[i,6]=this信息库2.快读库内名称值("政治面貌",myRow["政治面貌"],"");
thesheet.Cells[i,7]=this信息库2.快读库内名称值("二级行",myRow["二级行"],"");
thesheet.Cells[i,9]=myRow["员工编号"].ToString().PadLeft(5,'0'); // range.Cells[i,1]=myRow["姓名"];
// myvalues.SetValue(myRow["姓名"],i,1);
// string s1=myvalues.GetValue(i,1).ToString();
i++;
}
theWorkbook.Save();
theWorkbook.Close(这里有3个参数,不知道怎么填);
解决方案 »
- c# winform reportViewer显示报表的时候,页数老是不对
- 声卡采集系统怎么做呀?
- 如何在容器(比如GroupBox)中动态添加控件(比如PictureBox)?
- listview中如何通过嵌入checkbox以选中选择数据行?
- 系统如何支持GB18030
- 高分紧急求救,安装部署问题,高手们请进来看看.....................
- 如何Copy PictureBox 中的部分图像?
- 一个关于最大化的简单难题!!!!!
- vs2010 制作安装包无法选择盘符
- 谁能给我翻译一下下面的句子(中译英),急!
- 请问.NET中有没有类似于VB6里的CREATEOBJECT这样的方法?
- 急呀,放出300分,求一SQL语句,是关于主从表的,进来看看
基本表信息库类不用管它,在此问题不大
Class读取数据库_ds.LoadExecl函数忘记写了:
static public Excel.Workbook LoadExecl(string filename)
{
Excel.Application ExcelObj=new Excel.Application();
Excel.Workbook theWorkbook=ExcelObj.Workbooks.Open(filename,0,false,5,"","",true,Excel.XlPlatform.xlWindows,"\t",false,false,0,true);
return theWorkbook;
}
Excel.Workbook theWorkbook;中
theWorkbook.Close(,文件名,文件路径);
第一个参数不知道填什么,请大虾多多指教
SaveChanges, Filename, RouteWorkbookSaveChanges Variant 类型,可选。如果工作簿没有改变则忽略此参数;如果工作簿发生了改变并且在另外的窗口中也打开了该工作簿,则仍然忽略此参数;如果工作簿发生了改变并且没有在另外的窗口中打开,则此参数将指定是否在工作簿中保存所发生的更改。取值与操作如下表所示:值 作用
True 将改变保存到工作簿。如果该工作簿尚未命名,则使用 FileName 指定的名称。如果省略 FileName 参数,则要求用户输入文件名。
False 不将改变保存到此文件。
省略 显示一个对话框,要求用户决定是否保存所做的更改。 FileName Variant 类型,可选。以此文件名保存所做的更改。
RouteWorkbook Variant 类型,可选。如果指定工作簿不需要传送给下一个收件人(没有传送名单或已经传送),则忽略该参数。否则,Microsoft Excel 将按照下表所示处理传送。值 含义
True 将工作簿传送给下一个收件人。
False 将工作簿传送给下一个收件人。
省略 显示一个对话框,要求用户决定是否传送此工作簿。
与
theWorkbook.Close(true,"选区选民登记表.xls",@"D:\Documents and Settings\user\My Documents\新建文件夹 周勇\工作文档\选区选民登记表");
都报错"HRESULT中的异常:0x800A03EC。"
文件名和路径都在前面使用了,应该无问题。是什么原因
是成功的,但
theWorkbook.Close(true,"选区选民登记表.xls",@"D:\Documents and Settings\user\My Documents\新建文件夹 周勇\工作文档\选区选民登记表");
报错"HRESULT中的异常:0x800A03EC。"
为什么,哪里的错,大虾们看看