public static bool import_excel(string excelPath)
{
bool result = false;
//本地连接】
string myConnectString = "Server=localhost;Database=database;uid=sa;pwd=×××××;";
SqlConnection objConnection = new SqlConnection(myConnectString);
//创建一个excel应用程序
Excel.Application objApplication = new Excel.Application();
//创建一个工作簿
Excel._Workbook objWorkbook = objApplication.Workbooks.Add(excelPath);
Excel._Worksheet sh = new WorksheetClass();
try
{
string strSql = string.Empty;
StringBuilder objBuilder = new StringBuilder();
string mubiaotable = string.Empty;
//如果只想用程序控制该excel而不想让用户操作时候,可以设置为false
objApplication.Visible = false;
objApplication.UserControl = true;
// sheetName为Excel文件中Sheet的名子
string sheetName = string.Empty;
//然后通过它里面Excel.Application,Excel.Workbook,Excel.Worksheet,Excel.Range对像获得一些你想要的信息
for (int i = 1; i<= objWorkbook.Sheets.Count;i++)
{
取得excel 的工作表
sh = ( Excel._Worksheet)objWorkbook.Sheets[i];
objConnection.Open();
objBuilder.Append(sh.Name);
objBuilder.Append("$");
//excel工作表名
sheetName = objBuilder.ToString();
//sqlserver的表名
mubiaotable = objBuilder.ToString();
//把excel的工作表读出写入sqlserver表(sql语句经常出错)
strSql =" select * into "+mubiaotable+" from OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE="+excelPath+"',"+sheetName+")";
SqlCommand objCMD = new SqlCommand(strSql,objConnection);
objCMD.ExecuteNonQuery();
objConnection.Close();
//
objBuilder.Remove(0,objBuilder.Length);
}
result = true;
退出应用程序
objApplication.Quit();
}
catch(CSystem.CException ex)
{
throw new CSystem.CException(ex.ToString());
}
//释放进程
finally
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(objApplication);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objWorkbook);
System.Runtime.InteropServices.Marshal.ReleaseComObject(sh);
objApplication = null;
objWorkbook = null;
sh = null;
GC.Collect();
objConnection.Close();
objConnection = null;
}
return result;
}
没有合适的资源?快使用搜索试试~ 我知道了~
asp开发的工资系统
共553个文件
asp:229个
gif:197个
css:24个
需积分: 3 128 下载量 195 浏览量
2008-05-23
00:25:57
上传
评论
收藏 7.53MB RAR 举报
温馨提示
以前在网上收集的工资系统,界面做得不错,象vb风格
资源推荐
资源详情
资源评论
收起资源包目录
asp开发的工资系统 (553个子文件)
ToolBar.asp.bak05.7.6 6KB
Print_GZ_WG_ZG.asp 46KB
YG_GZ_HZ.asp 38KB
YG_GZ_YG1_B.asp 37KB
Print_GZ_WG_ZG_B.asp 31KB
YG_GZ_HZ_B.asp 28KB
huashi.asp 24KB
YG_GZ_YG3_T1_B.asp 20KB
YG_GZ_LWG_B.asp 20KB
YG_GZ_YG2_B.asp 19KB
YG_GZ_YG1_T_B.asp 19KB
YG_GZ_HZ3.asp 19KB
QueryDetail.asp 17KB
GZ_FrameAll.asp 17KB
Index.asp 16KB
YG_GZ_YG2.asp 16KB
YG_GZ_YG3_T1.asp 16KB
YG_GZ_YG3_T2.asp 16KB
YG_GZ_YG1_T.asp 16KB
YG_GZ_LWG.asp 16KB
YG_GZ_YG1.asp 16KB
YG_GZ_YG3.asp 16KB
Print_GZ_WG_YCC.asp 15KB
testa.asp 15KB
YG_GZ_HZ2_B.asp 15KB
FenXi_YueShouRu.asp 14KB
YG_GZ_HZ2.asp 14KB
QueryDetail3.asp 14KB
FenXi_YueShouRu2.asp 14KB
Add_Person.asp 13KB
Print_GZ_MingXi2_B.asp 13KB
Print_GZ_MingXi_LWG_B.asp 13KB
Print_GZ_MingXi5_LWT2_B.asp 13KB
Print_GZ_MingXi_B.asp 12KB
Print_100.asp 12KB
Print_GZ_MingXi4_ZGT_B.asp 12KB
Print_GZ_MingXi5_LWT1.asp 12KB
Print_GZ_MingXi5_LWT2.asp 12KB
Print_GZ_MingXi_LWG.asp 12KB
Print_GZ_MingXi4_ZGT.asp 12KB
Print_GZ_MingXi3.asp 12KB
Print_GZ_MingXi.asp 12KB
Print_GZ_MingXi2.asp 12KB
Query2.asp 12KB
Print_CountPerson.asp 11KB
Print_CountPersonNew.asp 11KB
Query3.asp 11KB
MakeNewMonthUpdate.asp 11KB
Print_GZ_WG_PY_B.asp 11KB
ToolBar.asp 10KB
Print_GZ_WG_PY.asp 10KB
Data_Import_Select.asp 10KB
UpLoadClass.asp 9KB
Modi_Tax_GS.asp 8KB
Print_Tax1.asp 8KB
Print_Tax2.asp 8KB
Print_Tax3.asp 8KB
Print_Tax1_2.asp 8KB
Print_Tax2_2.asp 8KB
Print_Tax3_2.asp 8KB
Print_WZ.asp 8KB
Data_Import_Where.asp 7KB
Modi_Depart.asp 7KB
TiaoZiLW.asp 7KB
TiaoZi.asp 7KB
Print_TaxCover.asp 7KB
TiaoZiJJ.asp 6KB
TiaoZiXRJ.asp 6KB
复件 Print_TaxCover.asp 6KB
复件 ToolBar.asp 6KB
Index_Right.asp 6KB
Print_TaxCover2.asp 6KB
Depart_Alert1.asp 6KB
DataCheck.asp 6KB
复件 Modi_Depart_Left.asp 5KB
Modi_Password.asp 5KB
upload.asp 5KB
GZ_Tax_MingXi.asp 5KB
Modi_JZTax.asp 4KB
tax1.asp 4KB
MakeNewMonth.asp 4KB
TestUser_HuiZong.asp 4KB
menu.asp 4KB
DX_upload.asp 4KB
Add_Tax_List.asp 4KB
Add_Tax_SJ.asp 4KB
GongZi_Top.asp 4KB
TestUser_LuRu.asp 4KB
GongZi_Left.asp 4KB
Data_Import_Select_ZC.asp 4KB
Data_Import_Select_ZC2.asp 4KB
tax2.asp 4KB
Data_ImportPrview_NF.asp 3KB
Haved_Add_List.asp 3KB
Haved_Del_List.asp 3KB
Add_Tax.asp 3KB
help.asp 3KB
JiangJin_Import_ZG.asp 3KB
Data_Import2.asp 3KB
YH_Tax2.asp 3KB
共 553 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
ice241018
- 粉丝: 165
- 资源: 52
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功