sql-servervb.netexcelwonderwarevba

Export data from Intouch to Excel


I'm programming an SCADA with Intouch R2 SP1. In this SCADA I have to make some reports in excel. The report it's simply writting 10 values into specific cells. The thing is that the code I'm using is working with Office 2010 which is the version I have in my computer, but when I installed the SCADA in the new computer, we bought a licence of Office 2016. When I try to generate the report with this computer it makes everything right except writting into the cells.

So my questions are this: Does anyone know how to export this data to an excel spreadsheet using the vb.net of Intouch Archestra Graphics? If not, is it possible to export data to excel from SQL Server with a SQL Query?

The code I'm using is below, here you can see that I'm copying the excel file to a new location changing it's name and I open the new excel file. After that I use the function WWPoke() to insert the desired values into 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"));

Thanks!


Solution

  • The problem is that the function WWPoke() is not compatible with 64-bit OS, it wasn't about the version of the Office. So what I've done is creating a .csv file and with an excel macro import the data to the report.