簡體   English   中英

將數據從Intouch導出到Excel

[英]Export data from Intouch to Excel

我正在用Intouch R2 SP1編程SCADA。 在此SCADA中,我必須使用Excel進行一些報告。 報告只是將10個值寫入特定的單元格。 問題是我正在使用的代碼與Office 2010配合使用,這是我在計算機上擁有的版本,但是當我在新計算機上安裝SCADA時,我們購買了Office 2016的許可證。當我嘗試生成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"));

謝謝!

問題在於函數WWPoke()與64位操作系統不兼容,它與Office版本無關。 因此,我要做的是創建一個.csv文件,並使用excel宏將數據導入到報表中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM