2

我正在使用 Intouch R2 SP1 对 SCADA 进行编程。在这个 SCADA 中,我必须在 excel 中制作一些报告。该报告只是将 10 个值写入特定单元格。问题是我正在使用的代码与我计算机中的版本 Office 2010 一起使用,但是当我在新计算机上安装 SCADA 时,我们购买了 Office 2016 的许可证。当我尝试生成用这台计算机报告它使一切正确,除了写入单元格。

所以我的问题是:有谁知道如何使用 Intouch Archestra Graphics 的 vb.net 将这些数据导出到 Excel 电子表格?如果没有,是否可以使用 SQL 查询将数据从 SQL Server 导出到 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"));

谢谢!

4

1 回答 1

1

问题是 WWPoke() 函数与 64 位操作系统不兼容,它与 Office 的版本无关。所以我所做的是创建一个 .csv 文件并使用 excel 宏将数据导入到报告中。

于 2018-01-22T07:13:40.833 回答