wincc生成excel
wincc的excel报表实例

wincc的excel报表打印实例因为ms word和excel的文档都支持html文本格式,因此可以先用word或excel做好模版,另存为Web页,然后将该html 改成jsp,将数据部分动态填入即可,不用很辛苦的调整格式word页面只要在jsp头设置如下指令:<%@page contentType="application/msword;charset=GBK" %>excel如下:<%@page contentType="application/vnd.ms-excel;charset=GBK" %>使用这种方式客户端必须安装有office软件,用户访问时将在ie中直接用wor d或excel打开该页面。
此方法优势是模板设计、调整方便,无需在服务器端使用复杂的POI或jxl技术,也无需在客户端使用ActiveX控件技术,更安全、方便,轻松实现较好的打印效果。
简单示例:使用word建立一文档,画表格如下:----------------------------| 用户名| 真实姓名| 性别|----------------------------| guest | 路人甲| 男|----------------------------保存为Web页test.htm,将test.htm改名为test.jsp,修改其中guest、路人甲、男为从数据库动态查询,如下:<%@ page contentType="application/msword;charset=GBK" %><%@ page import="java.sql.*" %><html xmlns:o="urn:schemas-micr osoft-com:office:office"xmlns:w="urn:schemas-microsoft-com:office:word"xmlns="http://www.w3.or g/TR/REC-html40"><head><meta http-equiv=C ontent-Type content="text/html; charset=GB2312"><meta name=ProgId content=W ord.Document><meta name=Generator content="Microsoft Word 9"><meta name=Originator content="Microsoft Wor d 9"><title>用户信息</title><!--[if gte mso 9]><xml><o:DocumentProperties><o:Author>evan zhao</o:Author><o:LastAuthor>evan zhao</o:LastAuthor><o:Revision>1</o:Revision><o:TotalTime>1</o:TotalTime><o:Created>2003-08-20T16:26:00Z</o:Created><o:LastSaved>2003-08-20T16:27:00Z</o:LastSaved><o:Pages>1</o:Pages><o:Company>taiping</o:Company><o:Lines>1</o:Lines><o:Paragraphs>1</o:Par agraphs><o:Version>9.2812</o:Version></o:DocumentProperties></xml><![endif]--><!--[if gte mso 9]><xml><w:WordDocument><w:PunctuationKerning><w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGr idV erticalSpacing><w:DisplayH orizontalDrawingGridEvery>0</w:D isplayH orizontalDrawingGr idEvery> <w:DisplayV erticalDrawingGr idEvery>2</w:D isplayVerticalDrawingGr idEvery><w:Compatibility><w:SpaceForUL><w:BalanceSingleByteDoubleByteW idth><w:DoNotLeaveBackslashAlone><w:ULTrailSpace><w:DoNotExpandShiftReturn><w:AdjustLineH eightInTable><w:UseFELayout></w:Compatibility></w:WordDocument></xml><![endif]--><style><!--/* Font Definitions */@font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-alt:SimSun;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:var iable;mso-font-signatur e:3 135135232 16 0 262145 0;}@font-face{font-family:"\@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:var iable;mso-font-signatur e:3 135135232 16 0 262145 0;}/* Style Definitions */p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;mso-pagination:none;font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman";mso-fareast-font-family:宋体;mso-font-kerning:1.0pt;}/* Page D efinitions */@page{mso-page-border-surround-header:no;mso-page-border-surround-footer:no;}@page Section1{size:595.3pt 841.9pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;mso-header-margin:42.55pt;mso-footer-margin:49.6pt;mso-paper-source:0;layout-gr id:15.6pt;}div.Section1{page:Section1;}--></style></head><body lang=ZH-CN style='tab-interval:21.0pt;text-justify-trim:punctuation'><div class=Section1 style='layout-gr id:15.6pt'><table border=1 cellspacing=0 cellpadding=0 style='border-collapse:collapse;border:none;mso-border-alt:solid w indowtext .5pt;mso-padding-alt:0cm 5.4pt 0cm 5.4pt'><tr><td w idth=189 valign=top style='width:142.0pt;border:solid w indowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'><p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman"; mso-hansi-font-family:"Times New Roman"'>用户名</span></p></td><td w idth=189 valign=top style='width:142.05pt;border:solid windowtext .5pt;border-left:none;mso-border-left-alt:solid w indowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'><p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman"; mso-hansi-font-family:"Times New Roman"'>真实姓名</span></p></td><td w idth=189 valign=top style='width:142.05pt;border:solid windowtext .5pt;border-left:none;mso-border-left-alt:solid w indowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'><p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman"; mso-hansi-font-family:"Times New Roman"'>性别</span></p></td></tr><%Class.forName("sun.jdbc.odbc.JdbcOdbcDr iver");String url="jdbc:odbc:mydb";//连接mydb数据库Connection con=Driver Manager.getC onnection (url, "", "");try{Statement stmt=con.createStatement();//查询employee表ResultSet rs=stmt.executeQuery("select user_name, real_name, gender from employee ");while(rs.next()){%><tr><td w idth=189 valign=top style='width:142.0pt;border:solid w indowtext .5pt;border-top:none;mso-border-top-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'><p class=MsoNormal><span lang=EN-US><%=rs.getString("user_name")%></span></p></td><td w idth=189 valign=top style='width:142.05pt;border-top:none;border-left:none;border-bottom:solid w indowtext .5pt;border-right:solid w indowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-bor der-left-alt:solid w indowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'><p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman"; mso-hansi-font-family:"Times New Roman"'><%=rs.getStr ing("real_name")%></span></p></td><td w idth=189 valign=top style='width:142.05pt;border-top:none;border-left:none;border-bottom:solid w indowtext .5pt;border-right:solid w indowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-bor der-left-alt:solid w indowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'><p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'><%=rs.getStr ing("gender")%></span></p></td></tr><%} // end whilers.close();stmt.close();} finally {con.close();}%></table><p class=MsoNormal><span lang=EN-US><![if !supportEmptyParas]> <![endif]><o:p></o:p></span></p>。
在Excel中访问WinCC变量归档数据

如何在Excel中访问WinCC变量归档数据————————————————————————————————作者:————————————————————————————————日期:1 功能说明在Microsoft office Excel中访问WinCC的历史数据,实现如下图所示的报表:图1: Excel中访问WinCC的历史数据生成报表选择日期后,可以生成当天的风机参数日报表(报表数据来自WinCC)。
2 软件环境本地计算机:Windows XP SP3英文版、WinCC7.0 SP2 ASIA、Microsoft office Excel 2003 远程计算机:Windows XP SP3英文版、WinCC7.0 SP2 ASIA、Microsoft office Excel 20033 WinCC/Connectivity Pack 介绍WinCC变量归档数据是以压缩的形式存储在数据库中,需要通过WinCC/Connectivity Pack提供的OLE-DB接口才能够解压并读取这些数据。
3.1 连接字符串“Provider=WinCCOLEDBProvider.1; Catalog= ***; Data Source= ***;“其中:Catalog:WinCC运行数据库的名称注意:当修改项目名称或在其它计算机上打开原项目时, Catalog会发生变化。
建议使用WinCC系统变量“@DatasourceNameRT” 获得当前的Catalog。
Data Source :服务器名称本地:“.\WinCC” 或者“<计算机名称>\WinCC”远程:“<计算机名称>\WinCC”3.2 查询语句“TAG:R,<ValueID or ValueName>,<TimeBegin>,<TimeEnd>[,<SQL_clause>][,<TimeStep>]”其中:ValueName:格式为“ArchiveName\V alue_Name”,可以使用多个名称。
WinCC_To_Excel

可以用C脚本,我已经照此例子实验,可以自动生成EXCEL文件给你转个论坛的帖子做参考取之于“民”用之于“民”,几段代码,希望对后来者有帮助,不要见笑。
1、记录脚本:同一卡片号的每一根钢的数据记录,有多少根,记多少行#include "apdefap.h"int gscAction( void ){#pragma code ()char FileName[20] = " ";double genshu,row,col;__object* pExcel = NULL;genshu=GetTagDouble("记数根数");SetTagDouble("根数记录",genshu);row=genshu+4;if((GetTagBit("钢温记录信号")==1)){pExcel = __object_create("Excel.Application.9"); //9表示用的是office 2000pExcel->Visible =0;pExcel->Workbooks ->Open ("e:\\LZEQ_HMI\\JILU.xls");//Cells(row,col)pExcel->Worksheets("sheet1")->Cells(row,1)->V alue=GetTagWord("记数根数");pExcel->Worksheets("sheet1")->Cells(row,2)->V alue=GetTagChar("开始时间");pExcel->Worksheets("sheet1")->Cells(row,3)->V alue=GetTagWord("1#高温计温度记录"); pExcel->Worksheets("sheet1")->Cells(row,4)->V alue=GetTagFloat("1#水箱流量记录"); pExcel->Worksheets("sheet1")->Cells(row,5)->V alue=GetTagWord("2#高温计温度记录"); pExcel->Worksheets("sheet1")->Cells(row,6)->V alue=GetTagFloat("2#水箱流量记录"); pExcel->Worksheets("sheet1")->Cells(row,7)->V alue=GetTagWord("3#高温计温度记录"); pExcel->Worksheets("sheet1")->Cells(row,8)->V alue=GetTagFloat("3#水箱流量记录"); pExcel->Worksheets("sheet1")->Cells(row,9)->V alue=GetTagWord("4#高温计温度记录"); pExcel->Worksheets("sheet1")->Cells(row,10)->V alue=GetTagWord("5#高温计温度记录"); pExcel->Worksheets("sheet1")->Cells(row,11)->V alue=GetTagFloat("4#水箱流量记录"); pExcel->Worksheets("sheet1")->Cells(row,12)->V alue=GetTagWord("6#高温计温度记录"); pExcel->Worksheets("sheet1")->Cells(row,13)->V alue=GetTagWord("7#高温计温度记录"); pExcel->Worksheets("sheet1")->Cells(row,14)->V alue=GetTagFloat("5#水箱流量记录"); pExcel->Worksheets("sheet1")->Cells(row,15)->V alue=GetTagWord("8#高温计温度记录"); pExcel->Worksheets("sheet1")->Cells(row,16)->V alue=GetTagChar("系统时间"); SetTagBit("钢温记录信号",0);}pExcel->ActiveWorkbook->Save;pExcel->Workbooks->Close();pExcel->Quit();__object_delete(pExcel);return 0;}2、存储脚本。
最新wincc生成excel

1给wincc中通过vbs写excel的方式做报表的初学者一点脚本我对该帖子不做任何限制,都可以自由拷贝使用。
方便初学者学习!//log子程序,40个数据记录,总共记录一周时间,写入excel,放到wincc 全局脚本中一分钟运行一次//如果是要整点报表也简单,判断一下当前的系统时间,t的初始值根据当前时间定义。
//本程序主要是演示数据记录的过程。
//在c:\建立一个excel文件,该文件可以是你的报表模版Option ExplicitFunction actionDim objExcelApp,objExcelbook,objExcelSheetDim tagshijian,sheetname,username,zhushiDim tagdayDim a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a1 8,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a3 5,a36,a37,a38,a39,a40Dim i,j,t,countDim msgDim patch,fnDim d,m,y,oh,mm,ssd=" "m="-"y="-"oh=":"mm=":"ss=""msg="记录报表成功"fn=CStr(Year(Now))&CStr(Month(Now))&CStr(Day(Now)) patch="c:\"&fn&".xls"Set a1=HMIRuntime.Tags("a1")Set a2=HMIRuntime.Tags("a2")Set a3=HMIRuntime.Tags("a3")Set a4=HMIRuntime.Tags("a4")Set a5=HMIRuntime.Tags("a5")Set a7=HMIRuntime.Tags("a7") Set a8=HMIRuntime.Tags("a8") Set a9=HMIRuntime.Tags("a9") Set a10=HMIRuntime.Tags("a10") Set a11=HMIRuntime.Tags("a11") Set a12=HMIRuntime.Tags("a12") Set a13=HMIRuntime.Tags("a13") Set a14=HMIRuntime.Tags("a14") Set a15=HMIRuntime.Tags("a15") Set a16=HMIRuntime.Tags("a16") Set a17=HMIRuntime.Tags("a17") Set a18=HMIRuntime.Tags("a18") Set a19=HMIRuntime.Tags("a19") Set a20=HMIRuntime.Tags("a20") Set a21=HMIRuntime.Tags("a21") Set a22=HMIRuntime.Tags("a22") Set a23=HMIRuntime.Tags("a23")Set a25=HMIRuntime.Tags("a25") Set a26=HMIRuntime.Tags("a26") Set a27=HMIRuntime.Tags("a27") Set a28=HMIRuntime.Tags("a28") Set a29=HMIRuntime.Tags("a29") Set a30=HMIRuntime.Tags("a30") Set a31=HMIRuntime.Tags("a31") Set a32=HMIRuntime.Tags("a32") Set a33=HMIRuntime.Tags("a33") Set a34=HMIRuntime.Tags("a34") Set a35=HMIRuntime.Tags("a35") Set a36=HMIRuntime.Tags("a36") Set a37=HMIRuntime.Tags("a37") Set a38=HMIRuntime.Tags("a38") Set a39=HMIRuntime.Tags("a39") Set a40=HMIRuntime.Tags("a40")Set count=HMIRuntime.Tags("count")sheetname="Sheet1"tagshijian=NowSet objExcelApp=CreateObject("Excel.Application") objExcelApp.visible=FalseobjExcelApp.workbooks.open "C:\Table.xls"objExcelApp.worksheets(sheetname).activatecount.Readt=count.Value +1If t<4 Thencount.Write 4t=4Elsecount.Write tEnd IfIf t>10080 Thencount.Write 3t=4End IfFor t=t To tWith objExcelApp.worksheets(sheetname).cells(t,1).value=tagshijiana1.Read.cells(t,2).value=a1.Valuea2.Read.cells(t,3).value=a2.Valuea3.Read.cells(t,4).value=a3.Valuea4.Read.cells(t,5).value=a4.Valuea5.Read.cells(t,6).value=a5.Valuea6.Read.cells(t,7).value=a6.Valuea7.Reada8.Read.cells(t,9).value=a8.Value a9.Read.cells(t,10).value=a9.Value a10.Read.cells(t,11).value=a10.Value a11.Read.cells(t,12).value=a11.Value a12.Read.cells(t,13).value=a12.Value a13.Read.cells(t,14).value=a13.Value a14.Read.cells(t,15).value=a14.Value a15.Read.cells(t,16).value=a15.Value a16.Reada17.Read.cells(t,18).value=a17.Value a18.Read.cells(t,19).value=a18.Value a19.Read.cells(t,20).value=a19.Value a20.Read.cells(t,21).value=a20.Value a21.Read.cells(t,22).value=a21.Value a22.Read.cells(t,23).value=a22.Value a23.Read.cells(t,24).value=a23.Value a24.Read.cells(t,25).value=a24.Value a25.Reada26.Read.cells(t,27).value=a26.Value a27.Read.cells(t,28).value=a27.Value a28.Read.cells(t,29).value=a28.Value a29.Read.cells(t,30).value=a29.Value a30.Read.cells(t,31).value=a30.Value a31.Read.cells(t,32).value=a31.Value a32.Read.cells(t,33).value=a32.Value a33.Read.cells(t,34).value=a33.Value a34.Reada35.Read.cells(t,36).value=a35.Value a36.Read.cells(t,37).value=a36.Value a37.Read.cells(t,38).value=a37.Value a38.Read.cells(t,39).value=a38.Value a39.Read.cells(t,40).value=a39.Value a40.Read.cells(t,41).value=a40.ValueEnd WithNextobjExcelApp.ActiveWorkbook.SaveobjExcelApp.ActiveWorkbook.closeobjExcelApp.ActiveWorkbook.QuitSet objExcelApp=NothingEnd Function//SAVE子程序//保存文件//读出系统时间,把文件保存为以日期为文件名的文件//每周日的23:59:10执行一次Option ExplicitFunction actionDim objExcelApp,objExcelbook,objExcelSheetDim sheetname,usernameDim tagdayDim i,j,tDim msgDim patch,fnfn=CStr(Year(Now))&CStr(Month(Now))&CStr(Day(Now))+CStr(Hour(Now)) &CStr(Minute(Now))patch="c:\"&fn&".xls"sheetname="Sheet1"Set objExcelApp=CreateObject("Excel.Application")objExcelApp.visible=FalseobjExcelApp.workbooks.open "C:\Table.xls"objExcelApp.worksheets(sheetname).activateobjExcelApp.ActiveWorkbook.SaveAs patchobjExcelApp.ActiveWorkbook.SaveobjExcelApp.ActiveWorkbook.closeobjExcelApp.ActiveWorkbook.QuitSet objExcelApp=NothingEnd Function//delete子程序//删除模版,拷贝空白模版到当前目录//有人会问,为什么不用vb清空当前已经记录数据的模版文件//问的好,如果这个模版里面已经存了几万条数据了呢?//所以最快的方法是用vc脚本,将当前模版删除,拷贝一个空的模版到c:/ /每周日的23:59:30执行一次#include "apdefap.h"int gscAction( void ){#pragma option(mbcs)// WINCC:TAGNAME_SECTION_START// syntax: #define TagNameInAction "DMTagName"// next TagID : 1// WINCC:TAGNAME_SECTION_END#pragma code("kernel32.dll")long CopyFileA(LPCTSTR,LPCTSTR,long);long DeleteFileA(LPCTSTR);#pragma code()DeleteFileA("C:\\Table.xls");CopyFileA("C:\\bak\\Table.xls","C:\\Table.xls",TRUE);// WINCC:PICNAME_SECTION_START// syntax: #define PicNameInAction "PictureName"// next PicID : 1// WINCC:PICNAME_SECTION_ENDreturn 0;}2。
wicc 写EXCEL 表格

3 其他图形代码
Hale Waihona Puke WICC 写EXCEL 表格
1. WINCC新建EXCEL,并把变量值和公式值计算后的值写入 EXCEL表格中
On Error Resume Next Dim objExcelApp Set objExcelApp=CreateObject("Excel.Application")'创建表格对象模型 objExcelApp.Visible=False objExcelApp.Workbooks.add objExcelApp.worksheets(1).name="我的" objExcelApp.Worksheets("我的").Activate '激活工作表格 With objExcelApp.worksheets("我的") '数据写 .cells(2,2).value = HMIRuntime.Tags("EXCEL_1").read .cells(2,3).value= HMIRuntime.Tags("EXCEL_2").read .cells(3,2).value= HMIRuntime.Tags("EXCEL_3").read .cells(3,3).Formula = HMIRuntime.Tags("EXCEL_4").read .cells(4,2).Formula = "=MAX(R2C2:R3C2)" .cells(4,3).Formula = "=AVERAGE(R2C2:R3C3)" End With
objExcelApp.Activeworkbook.saveAs "e:\我的.xls" objExcelApp.Workbooks.Close'退出工作簿 objExcelApp.Quit '表格模型退出 Set objExcelApp= Nothing'释放资源 Set fso=Nothing'释放资源
WINCC嵌入式EXCEL报表系统使用手册

WINCC 嵌入式EXCEL 报表系统使用手册1、打开报表画面点击主画面中“报表”按钮,打开报表画面:2、界面介绍报表画面功能介绍时间设置3、选择报表文件在“报表选择”栏中选择需要生成报表的名称:4、选择报表类型在“类型选择”栏选择报表类型:日报表、月报表、年报表、自由报表,具体介绍如下:●日报表——为一天的报表数据,每小时产生一个记录,共24条记录,时间为“00:00:00”至“23:59:59”。
●月报表——为一月的报表数据,每天产生一个记录,根据月份的不同分别产生28-31条记录,时间为“01 00:00:00”至“30 23:59:59”(或“2823:59:59”/“29 23:59:59”/“31 23:59:59”)。
●年报表——为一年的报表数据,每月产生一个记录,共12条记录,时间为“01-01 00:00:00”至“12-31 23:59:59”。
●自由报表——为指定时间段的报表数据,时间段由“开始时间”和“结束时间”共同决定,每一个“时间间隔”产生一个记录,记录条数由时间段和时间间隔决定。
5、设置报表时间根据报表类型,选择报表时间。
点击“日历”可以打开日历控件,控件中可以快速选择日月年,也可以通过下拉窗口进行选择。
当为日报表时,需要设置“年”、“月”、“日”;当为月报表时,需要设置“年”、“月”;当为年报表时,需要设置“年”;当为自由报表时,需要设置开始和结束时间的“年”、“月”,“日”、“时”、“分”等全部项,间隔时间也需要设置。
6、生成报表当“报表选择”、“类型选择”和时间选择均设置完成后,点击“生成报表”按钮,系统将开始在右边表格中生成出报表,在生成报表的过程中能看见表格中数据逐渐显示,也能通过下方进度条看见完成情况。
生成报表时,空数据区用“#”填充,错误数据区用“##”填充,报表生成完毕后将有“成功生成数据文件!”提示。
同时,报表生成后将自动保存到项目中“report”文件夹下。
在wincc 中怎么做才能把报表生成按日期的excel 文件

在wincc 中怎么做才能把报表生成按日期的excel 文件在wincc 中怎么做才能把报表生成按日期的Excel 文件VBS脚本实现,就是把文件名称以变量的形式表示。
参考'关闭保存Dim patch,filenamefilename=CStr(Year(Now))&CStr(Month(Now))&CStr(Day(Now))&CStr(Hour(N ow))+CStr(Minute(Now))&CStr(Second(Now))patch= "d:\"&filename&"demo.xls"objExcelApp.ActiveWorkbook.SaveAs patch objExcelApp.Workbooks.Close objExcelApp.QuitSet objExcelApp= Nothing对于Excel报表,用VBS最灵活,Excel 定义好格式后wincc来填空,平均累计值就用Excel 的功能。
Dim excelappDim aa,bb,ccSet excelapp = CreateObject("Excel.Application") Set aa = HMIRuntime.tags("tag1")excelapp.visible = False'Trueexcelapp.workbooks.open "D:\excel.xls" bb = Now'getcurrent_datetime()aa.ReadMsgBox CStr(bb)excelapp.cells(1,1).value = "rrrrrr"'111111excelapp.cells(1,2).value = CStr(bb)excelapp.cells(2,2).value = CStr(aa.value) excelapp.cells(3,2).value = CInt(aa.value) excelapp.cells(4,2).value = CSng(aa.value)excelapp.cells(5,2).value = CDbl(aa.value) excelapp.cells(6,2).value = CLng(aa.value) excelapp.cells(3,3).value = ScreenItems("33").outputvalue excelapp.cells(4,4).value = ScreenItems("35").outputvaluecc = "D:\excel" + Mid(CStr(bb), 1, 4)+ Mid(CStr(bb), 6, 2)+Mid(CStr(bb), 9, 2)+ Mid(CStr(bb), 12, 2)+ Mid(CStr(bb), 15, 2)+ Mid(CStr(bb), 18, 2) + ".xls"MsgBox ccexcelapp.DisplayAlerts = False '对打开的文件,直接保存时,避免弹出对话框窗口,而是直接覆盖excelapp.activeworkbook.saveas cc '根据当前日期时间,另存为新的文件'excelapp.activeworkbook.save ’对打开的文件,直接保存'excelapp.activeworkbook.saveAs "D:\excelcopy.xls" ’直接另存为新的文件excelapp.workbooks.closeexcelapp.quitSet excelapp = Nothing这个报表的数据采集没有难度;唯一的难度在于4班3 倒后,每个月班的出勤日是不一样的,这样对于月报来说,计算出本月每个班的出勤日是需要些算法的。
excel 表格和wincc的报表

如何使用WinCC DataMonitor基于Web发布浏览Excel报表文档 How to use WinCC DataMonitor publish and view excel document base on Web摘要本文介绍使用 WinCC DataMonitor 的 "Excel Workbooks",通过 Excel 表格显示 WinCC 项目的过程值、归档变量值和归档消息。
并可以通过 Web 发布浏览访问数据。
关键词WinCC,DataMonitor,ExcelKey Words WinCC,DataMonitor,ExcelA&D Service & Support Page 2-14目录1.WinCC DataMonitor是什么 ? (4)1.1 简介 (4)1.2 WinCC DataMonitor 的主要功能 (4)2.使用WinCC DataMonitor基于Web发布浏览Excel报表文档 (7)2.1 使用“Excel 工作簿向导”组态发布 Excel 工作簿 (7)2.2 在线显示浏览Excel 工作簿 (12)A&D Service & Support Page 3-141.WinCC DataMonitor是什么 ?DataMonitor 是 SIMATIC WinCC 工厂智能中用于数据显示和分析的一个组件,它基于WinCC 的实时、历史数据进行车间管理级的数据汇总和分析,借助标准工具(例如微软的 IE 浏览器或者 MS Office Excel)可以显示并分析 WinCC 上的过程信息和历史数据。
1.1 简介SIMATIC WinCC/DataMonitor 提供用于显示交互数据及分析当前过程状态和历史数据的分析工具集合。
DataMonitor 客户端是纯粹用于显示和评估来自 WinCC 的过程值或来自 WinCC 长期归档服务器的数据的系统。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
给wincc中通过vbs写excel的方式做报表的初学者一点脚本我对该帖子不做任何限制,都可以自由拷贝使用。
方便初学者学习!//log子程序,40个数据记录,总共记录一周时间,写入excel,放到wincc 全局脚本中一分钟运行一次//如果是要整点报表也简单,判断一下当前的系统时间,t的初始值根据当前时间定义。
//本程序主要是演示数据记录的过程。
//在c:\建立一个excel文件,该文件可以是你的报表模版Option ExplicitFunction actionDim objExcelApp,objExcelbook,objExcelSheetDim tagshijian,sheetname,username,zhushiDim tagdayDim a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21, a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40 Dim i,j,t,countDim msgDim patch,fnDim d,m,y,oh,mm,ssd=" "m="-"y="-"oh=":"mm=":"ss=""msg="记录报表成功"fn=CStr(Year(Now))&CStr(Month(Now))&CStr(Day(Now))patch="c:\"&fn&".xls"Set a1=HMIRuntime.Tags("a1")Set a2=HMIRuntime.Tags("a2")Set a3=HMIRuntime.Tags("a3")Set a4=HMIRuntime.Tags("a4")Set a5=HMIRuntime.Tags("a5")Set a6=HMIRuntime.Tags("a6")Set a7=HMIRuntime.Tags("a7")Set a8=HMIRuntime.Tags("a8")Set a9=HMIRuntime.Tags("a9")Set a10=HMIRuntime.Tags("a10")Set a11=HMIRuntime.Tags("a11")Set a12=HMIRuntime.Tags("a12")Set a13=HMIRuntime.Tags("a13")Set a14=HMIRuntime.Tags("a14")Set a15=HMIRuntime.Tags("a15")Set a16=HMIRuntime.Tags("a16")Set a17=HMIRuntime.Tags("a17")Set a18=HMIRuntime.Tags("a18")Set a19=HMIRuntime.Tags("a19")Set a20=HMIRuntime.Tags("a20")Set a21=HMIRuntime.Tags("a21")Set a22=HMIRuntime.Tags("a22")Set a23=HMIRuntime.Tags("a23")Set a24=HMIRuntime.Tags("a24")Set a25=HMIRuntime.Tags("a25")Set a26=HMIRuntime.Tags("a26")Set a27=HMIRuntime.Tags("a27")Set a28=HMIRuntime.Tags("a28")Set a29=HMIRuntime.Tags("a29")Set a30=HMIRuntime.Tags("a30")Set a31=HMIRuntime.Tags("a31")Set a32=HMIRuntime.Tags("a32")Set a33=HMIRuntime.Tags("a33")Set a34=HMIRuntime.Tags("a34")Set a35=HMIRuntime.Tags("a35")Set a36=HMIRuntime.Tags("a36")Set a37=HMIRuntime.Tags("a37")Set a38=HMIRuntime.Tags("a38")Set a39=HMIRuntime.Tags("a39")Set a40=HMIRuntime.Tags("a40")Set count=HMIRuntime.Tags("count")sheetname="Sheet1"tagshijian=NowSet objExcelApp=CreateObject("Excel.Application") objExcelApp.visible=FalseobjExcelApp.workbooks.open "C:\Table.xls"objExcelApp.worksheets(sheetname).activatecount.Readt=count.Value +1If t<4 Thencount.Write 4t=4Elsecount.Write tEnd IfIf t>10080 Thencount.Write 3t=4End IfFor t=t To tWith objExcelApp.worksheets(sheetname).cells(t,1).value=tagshijiana1.Read.cells(t,2).value=a1.Valuea2.Read.cells(t,3).value=a2.Valuea3.Read.cells(t,4).value=a3.Valuea4.Read.cells(t,5).value=a4.Valuea5.Read.cells(t,6).value=a5.Valuea6.Read.cells(t,7).value=a6.Valuea7.Read.cells(t,8).value=a7.Valuea8.Read.cells(t,9).value=a8.Valuea9.Read.cells(t,10).value=a9.Valuea10.Read.cells(t,11).value=a10.Valuea11.Read.cells(t,12).value=a11.Valuea12.Read.cells(t,13).value=a12.Valuea13.Read.cells(t,14).value=a13.Valuea14.Read.cells(t,15).value=a14.Valuea15.Read.cells(t,16).value=a15.Valuea16.Read.cells(t,17).value=a16.Valuea17.Read.cells(t,18).value=a17.Valuea18.Read.cells(t,19).value=a18.Valuea19.Read.cells(t,20).value=a19.Valuea20.Read.cells(t,21).value=a20.Value a21.Read.cells(t,22).value=a21.Value a22.Read.cells(t,23).value=a22.Value a23.Read.cells(t,24).value=a23.Value a24.Read.cells(t,25).value=a24.Value a25.Read.cells(t,26).value=a25.Value a26.Read.cells(t,27).value=a26.Value a27.Read.cells(t,28).value=a27.Value a28.Read.cells(t,29).value=a28.Value a29.Read.cells(t,30).value=a29.Value a30.Read.cells(t,31).value=a30.Value a31.Read.cells(t,32).value=a31.Value a32.Read.cells(t,33).value=a32.Value a33.Read.cells(t,34).value=a33.Value a34.Read.cells(t,35).value=a34.Value a35.Read.cells(t,36).value=a35.Value a36.Read.cells(t,37).value=a36.Value a37.Read.cells(t,38).value=a37.Value a38.Read.cells(t,39).value=a38.Value a39.Read.cells(t,40).value=a39.Value a40.Read.cells(t,41).value=a40.ValueEnd WithNextobjExcelApp.ActiveWorkbook.SaveobjExcelApp.ActiveWorkbook.closeobjExcelApp.ActiveWorkbook.QuitSet objExcelApp=NothingEnd Function//SAVE子程序//保存文件//读出系统时间,把文件保存为以日期为文件名的文件//每周日的23:59:10执行一次Option ExplicitFunction actionDim objExcelApp,objExcelbook,objExcelSheetDim sheetname,usernameDim tagdayDim i,j,tDim msgDim patch,fnfn=CStr(Year(Now))&CStr(Month(Now))&CStr(Day(Now))+CStr(Hour(Now))&CStr(Minute (Now))patch="c:\"&fn&".xls"sheetname="Sheet1"Set objExcelApp=CreateObject("Excel.Application")objExcelApp.visible=FalseobjExcelApp.workbooks.open "C:\Table.xls"objExcelApp.worksheets(sheetname).activateobjExcelApp.ActiveWorkbook.SaveAs patchobjExcelApp.ActiveWorkbook.SaveobjExcelApp.ActiveWorkbook.closeobjExcelApp.ActiveWorkbook.QuitSet objExcelApp=NothingEnd Function//delete子程序//删除模版,拷贝空白模版到当前目录//有人会问,为什么不用vb清空当前已经记录数据的模版文件//问的好,如果这个模版里面已经存了几万条数据了呢?//所以最快的方法是用vc脚本,将当前模版删除,拷贝一个空的模版到c://每周日的23:59:30执行一次#include "apdefap.h"int gscAction( void ){#pragma option(mbcs)// WINCC:TAGNAME_SECTION_START// syntax: #define TagNameInAction "DMTagName"// next TagID : 1// WINCC:TAGNAME_SECTION_END#pragma code("kernel32.dll")long CopyFileA(LPCTSTR,LPCTSTR,long);long DeleteFileA(LPCTSTR);#pragma code()DeleteFileA("C:\\Table.xls");CopyFileA("C:\\bak\\Table.xls","C:\\Table.xls",TRUE);// WINCC:PICNAME_SECTION_START// syntax: #define PicNameInAction "PictureName"// next PicID : 1// WINCC:PICNAME_SECTION_ENDreturn 0;}。