首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将数据从Intouch导出到Excel

将数据从Intouch导出到Excel
EN

Stack Overflow用户
提问于 2018-01-18 10:43:43
回答 1查看 2.5K关注 0票数 2

我正在用Intouch R2 SP1编写一个SCADA程序。在这个SCADA中,我必须用excel做一些报告。报告简单地将10个值写入特定的单元格中。问题是,我正在使用的代码是Office 2010,这是我在电脑中的版本,但当我在新计算机上安装SCADA时,我们购买了Office 2016的许可证。当我试图用这台计算机生成报告时,除了写进单元格之外,一切都是正确的。

所以,我的问题是:有人知道如何使用Intouch的vb.net图形将这些数据导出到excel电子表格中吗?如果没有,是否可以使用SQL查询从Server导出数据到excel?

下面是我使用的代码,在这里您可以看到,我正在将excel文件复制到一个新位置,更改它的名称,然后打开新的excel文件。之后,我使用函数WWPoke()将所需的值插入到Excel中。

代码语言:javascript
复制
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"));

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-22 07:13:40

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48319360

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档