如何将WinCC归档的历史数据导出为EXCEL?
常用方法:1使用WinCC标准控件的工具按钮
1 .1在线趋势控件
1.2在线表格控件
2 使用Excel模板文件
3 使用“SQL Server Import/Export”向导
C脚本方法:
#include "apdefap.h"
int gscAction( void )
{
#pragma code("kernel32.dll");
void GetLocalTime(SYSTEMTIME* lpst);
#pragma code();
SYSTEMTIME st;
const char param[512][30]={
"fq02_pv","cod2_pv","nh3_n2#_pv","fq01_pv","cod1_pv","nh3_n1#_pv","DO_shc_pv","SS_shc_pv","gfj_1#gfj_A_PV","gfj_2#gfj_A_PV","LT_jsbf_PV","LT_psj_PV",
"LT_lc801_PV","LT_lc1_PV","LT_lc2_PV","LT_lc3_PV","LT_lc4_PV"};
char VarName[512][30]={
"Date","备用1","备用2","出水流量","出水COD","出水氨氮","进水流量","进水COD","进水氨氮","生化池溶解氧","生化池污泥浓度","1#鼓风机频率","2#鼓风机电流","进水房液位","配水井液位",
"滤池集水池液位","1#滤池液位","2#滤池液位","3#滤池液位","4#滤池液位"};
省略。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
sprintf(aa1temp,"%4d",st.wYear);
sprintf(aatemp,"%02d",st.wMonth);//st.wMonth????????
strcpy(temp,"E:\\t");
strcat(temp,aa1temp);
strcat(temp,aatemp);
strcat(temp,".xls");
省略。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
fp=fopen(temp,"a");
if(fp==NULL) return 0 ;
if(b1==1)
{
for(i=0;i<30;i++)//???VarName??????
{
fprintf(fp,"%s\t",VarName[i]);
}
fprintf(fp,"\n");
b1=0;
SetTagBit("b1",1);
}
strcpy(NameTemp,temp);
fprintf(fp,"%4d-%02d-%02d %02d:%02d:%02d\t",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
fprintf(fp,"%s\t%s\t",GetTagChar("@CurrentUser"),GetTagChar("@mode_show"));
for(x=0;param[x][0]!=0&&x<512;x++)
{
fprintf(fp,"%5.1f \t",GetTagFloat(param[x]));
}
fprintf(fp,"\n");
fclose (fp);
return 0;