找不到Server.MapPath方法的命名空间

Serve.MapPath 使用

 习惯了直接用Serve.Map方法来映射一个物理路径,但在类库中直接这么写是不对的,因为原来的脚本类都默认继承于Page类,这样就可以直接使用,但在自己写的类库中药使用的话,必须引用System.Web,然后在下面的代码中使用HttpContent.Current.Server.MapPath()方法

If biaspath <> "" Then booknum = booknum + 1 oBooks.Open(Server.MapPath("~") + biaspath) oSheet1 = oBooks.Item(booknum).Worksheets(1) oSheet1.Copy(, oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count)) oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count).name = "偏性&線性" oExcel.ActiveSheet.Protect(Password:="m1s3a3") oExcel.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True) End If If grrpath <> "" Then booknum = booknum + 1 oBooks.Open(Server.MapPath("~") + grrpath) oSheet1 = oBooks.Item(booknum).Worksheets(1) oSheet1.Copy(, oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count)) oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count).name = "GRR" oExcel.ActiveSheet.Protect(Password:="m1s3a3") oExcel.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True) End If If stabpath <> "" Then booknum = booknum + 1 oBooks.Open(Server.MapPath("~") + stabpath) oSheet1 = oBooks.Item(booknum).Worksheets(1) oSheet1.Copy(, oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count)) oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count).name = "穩定性" oExcel.ActiveSheet.Protect(Password:="m1s3a3") oExcel.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True) End If 'mintab If grrpath <> "" Then booknum = booknum + 1 oBooks.Open(Server.MapPath("~") + "\samplefile\MinTab.xls") oSheet1 = oBooks.Item(booknum).Worksheets(1) oSheet1.Copy(, oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count)) oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count).name = "Minitab GRR驗證數據" oExcel.ActiveSheet.Cells(1, 7).formula = "=MAX(GRR!AJ:AJ)" oExcel.ActiveSheet.Cells(1, 10).formula = "=COUNTA(GRR!C7:Z7)" oExcel.ActiveSheet.Protect(Password:="m1s3a3") oExcel.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True) oExcel.Visible = False 'oExcel.DisplayAlerts = False End If If cgkpath <> "" Then booknum = booknum + 1 oBooks.Open(Server.MapPath("~") + cgkpath) oSheet1 = oBooks.Item(booknum).Worksheets(2) oSheet1.Copy(, oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count)) ' oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count).name = "Minitab GRR驗證數據" 'oExcel.ActiveSheet.Cells(1, 7).formula = "=MAX(GRR!AJ:AJ)" 'oExcel.ActiveSheet.Cells(1, 10).formula = "=COUNTA(GRR!C7:Z7)" 'oExcel.ActiveSheet.Protect(Password:="m1s3a3") 'oExcel.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True) End If If booknum > 1 Then oSheet1 = oBooks.Item(1).Worksheets(1) 'oExcel.ActiveSheet.Unprotect(Password:="m1s3a3") oSheet1.Move(, oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count)) oExcel.ActiveSheet.Protect(Password:="m1s3a3") oExcel.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True) If oBooks.Item(1).Worksheets(1).name = "單點判偏性" Then oBooks.Item(1).Worksheets(1).Move(, oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count)) oExcel.ActiveSheet.Protect(Password:="m1s3a3") oExcel.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True) End If End If执行执行oSheet1.Move(, oBooks.Item(1).Sheets(oBooks.Item(1).Sheets.Count))报错
最新发布
09-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值