将数据从 Intouch 导出到 Excel
Export data from Intouch to Excel
我正在使用 Intouch R2 SP1 对 SCADA 进行编程。在这个 SCADA 中,我必须在 excel 中做一些报告。报告只是将 10 个值写入特定单元格。问题是我使用的代码与我电脑中的 Office 2010 一起使用,但是当我在新电脑上安装 SCADA 时,我们购买了 Office 2016 的许可证。当我尝试生成用这台电脑报告它除了写入单元格外一切正常。
所以我的问题是:有人知道如何使用 Intouch Archestra Graphics 的 vb.net 将此数据导出到 excel 电子表格吗?如果没有,是否可以使用 SQL 查询将数据从 SQL 服务器导出到 excel?
我使用的代码如下,在这里您可以看到我正在将 excel 文件复制到新位置并更改其名称,然后我打开新的 excel 文件。之后,我使用函数 WWPoke() 将所需的值插入 Excel.
dim sourceDir as string;
dim destDir as string;
dim fileName as string;
dim destName as string;
dim sourceFile as string;
dim destFile as string;
dim modo as System.IO.FileMode;
dim fechaini as string;
sourceDir = "C:\MIGRA\SCADA\Acesur_Cogeneracion";
destDir = "C:\InformesAcesur";
fileName = "Informe.xls";
destName = InTouch:$Day + "" + InTouch:$Month + "" + InTouch:$Year + "_" +
InTouch:$Hour+ "" + InTouch:$Minute + ".xls";
sourceFile = System.IO.Path.Combine(sourceDir,fileName);
destFile = destDir + "\" + destName;
'I copy the original file to the new location
System.IO.File.Copy(sourceFile,destFile,true);
'I open the copied file
System.Diagnostics.Process.Start("excel.exe",destFile);
'I send the data to excel - THIS IS THE PART THAT'S NOT WORKING
WWPoke( "excel.exe", "Hoja1", "F10C4", FechaInicio);
WWPoke( "excel.exe", "Hoja1", "F11C4", FechaFin);
WWPoke( "excel.exe", "Hoja1", "F20C4", StringFromReal(E,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F21C4", StringFromReal(Q,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F22C4", StringFromReal(V,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F28C4", StringFromReal(REE,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F34C4", StringFromReal(FT001,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F35C4", StringFromReal(FT002,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F36C4", StringFromReal(FT003,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F37C4", StringFromReal(FT004,2,"f"));
谢谢!
问题是 WWPoke() 函数与 64 位不兼容 OS,这与 Office 的版本无关。所以我所做的是创建一个 .csv 文件并使用 excel 宏将数据导入报告。
我正在使用 Intouch R2 SP1 对 SCADA 进行编程。在这个 SCADA 中,我必须在 excel 中做一些报告。报告只是将 10 个值写入特定单元格。问题是我使用的代码与我电脑中的 Office 2010 一起使用,但是当我在新电脑上安装 SCADA 时,我们购买了 Office 2016 的许可证。当我尝试生成用这台电脑报告它除了写入单元格外一切正常。
所以我的问题是:有人知道如何使用 Intouch Archestra Graphics 的 vb.net 将此数据导出到 excel 电子表格吗?如果没有,是否可以使用 SQL 查询将数据从 SQL 服务器导出到 excel?
我使用的代码如下,在这里您可以看到我正在将 excel 文件复制到新位置并更改其名称,然后我打开新的 excel 文件。之后,我使用函数 WWPoke() 将所需的值插入 Excel.
dim sourceDir as string;
dim destDir as string;
dim fileName as string;
dim destName as string;
dim sourceFile as string;
dim destFile as string;
dim modo as System.IO.FileMode;
dim fechaini as string;
sourceDir = "C:\MIGRA\SCADA\Acesur_Cogeneracion";
destDir = "C:\InformesAcesur";
fileName = "Informe.xls";
destName = InTouch:$Day + "" + InTouch:$Month + "" + InTouch:$Year + "_" +
InTouch:$Hour+ "" + InTouch:$Minute + ".xls";
sourceFile = System.IO.Path.Combine(sourceDir,fileName);
destFile = destDir + "\" + destName;
'I copy the original file to the new location
System.IO.File.Copy(sourceFile,destFile,true);
'I open the copied file
System.Diagnostics.Process.Start("excel.exe",destFile);
'I send the data to excel - THIS IS THE PART THAT'S NOT WORKING
WWPoke( "excel.exe", "Hoja1", "F10C4", FechaInicio);
WWPoke( "excel.exe", "Hoja1", "F11C4", FechaFin);
WWPoke( "excel.exe", "Hoja1", "F20C4", StringFromReal(E,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F21C4", StringFromReal(Q,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F22C4", StringFromReal(V,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F28C4", StringFromReal(REE,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F34C4", StringFromReal(FT001,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F35C4", StringFromReal(FT002,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F36C4", StringFromReal(FT003,2,"f"));
WWPoke( "excel.exe", "Hoja1", "F37C4", StringFromReal(FT004,2,"f"));
谢谢!
问题是 WWPoke() 函数与 64 位不兼容 OS,这与 Office 的版本无关。所以我所做的是创建一个 .csv 文件并使用 excel 宏将数据导入报告。