Dim lj As String=Functions.Execute("获取模板文件")
If lj<>"" Then
Dim Book As New XLS.Book(lj)
Dim Ifo As new FileInfo(lj)
Dim sr As String
sr=Ifo.Name.Replace(Ifo.Extension,"")
lj=lj.Replace(sr,rwh)
Dim fl As String =lj.Replace("Attachments","Reports")
book.AddDataTable("gd","cderp","Sel ect * from {gd} a where gdno='" & rwh & "'" )
book.AddDataTable("gddd","cderp","Se lect * from {gddd} a inner join " & _
"(Sel ect gdno,加工type,QC要求,送货方式,包装方式,首件确认,制单人,审核人,gdtype from gd) b on a.gdno=b.gdno" & _
" inner join (sel ect 分支机构,khno as kh from cuinfo ) c on c.kh=a.khno" & _
" where a.gdno='" & rwh & "'" )
book.AddDataTable("gdysdetails","cderp","sel ect * from gdysdetails a left join (sel ect gdno,prid,材料count as 用料数 from gd用料明细) b on a.prid=b.prid and a.gdno=b.gdno " & _
" left join (sel ect guid,count as CTPcount from gdgx where gx='CTP') d on a.prid=d.guid where a.gdno='" & rwh & "'")
book.AddDataTable("gdgx","cderp","Sel ect * from {gdgx} a where gdno='" & rwh & "'" )
book.AddRelation("gd","gdno","gddd","gdno")
book.AddRelation("gd","gdno","gdysdetails","gdno")
book.AddRelation("gd","gdno","gdgx","gdno")
Book.Build() '生成细节区
Book.Save(fl)
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Ws.Protect(Password:=Format(Date.now,"yyMMdd"))
Wb.Save
App.Visible = True
将报表生成好,单独使用加密代码也是无法加密:现象都是部分单元格加密,部分没加密,office版本是 office365.
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(ProjectPath & "reports\订单.xlsx")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Ws.Protect(Password:="foxtabletest")
Wb.Save
App.Visible = True