ADO OpenSchema(adSchemaColumns) fails for the odd excel file - c++

I have code that reads column headers from MS Excel files using C++ & ADO. I got this one Excel file from someone for which the OpenSchema(adSchemaColumns) command fails (The error is: 0x800A0CB3: "Object or provider is not capable of performing requested operation"). To narrow the problem, I removed all data from the file & deleted all columns except column A. If I delete column A as well, OpenSchema succeeds. Otherwise, it fails. I compared column A to other columns using the excel CELL function: format, protection, contents: but there is no difference.
In any case, OpenSchema(adSchemaTables) does NOT fail.
This is an excerpt of the C++ code I use, built with VS2010:
#import "C:\Program Files\Common Files\System\ADO\msado28.tlb" no_namespace rename("EOF", "adoEOF") rename("BOF", "adoBOF")
_ConnectionPtr pCon;
pCon.CreateInstance(__uuidof(Connection))
pCon->Open(connStr, "", "", NULL)
_RecordsetPtr pSchema = NULL;
pSchema = pCon->OpenSchema(adSchemaColumns);
This is a link to the faulty excel file:
workbook.xls
I use MS Excel 2010.
To reproduce: run the code on unchanged workbook.xls - fails. Delete column A - succeeds.
Any ideas are welcome,
Thank you

Related

LibXL: excel cross-sheet formulas not updated

I'm dealing with a problem with libXL and Office365.
I created an Excel file with Office 365: a simple formula which shows the content of a cell from another sheet. Then I proceeded to write something in that source cell through libXl. When I open the output file the formula is not calculated until I press CTRL+ALT+SHIFT+F9.
If I create the xlsx file from Office 2013 then the formula is correctly updated.
Couldn' find anything on their website whether O365 is supported or not.
Here's the code to reproduce the issue, (I can provide the two input xlsx files if needed):
#include "stdafx.h"
#include "libxl.h"
using namespace libxl;
int main()
{
Book* book = xlCreateXMLBook();
// xlsx file created by Office 2013
if (book->load(L"office2013.xlsx"))
{
Sheet* sheet = book->getSheet(0);
if (sheet)
sheet->writeNum(2, 2, 42);
book->save(L"okay.xlsx"); // works correctly when opened
}
// xlsx file created by O365
if (book->load(L"office365.xlsx"))
{
Sheet* sheet = book->getSheet(0);
if (sheet)
sheet->writeNum(2, 2, 42);
book->save(L"bugged.xlsx"); // must press CTRL+ALT+SHIFT+F9 to see '42' in the second sheet
}
book->release();
return 0;
}
This is the source sheet (number 42 written by the above code): https://i.stack.imgur.com/hp7Ti.png
This is the not working formula (written in Excel): https://i.stack.imgur.com/BhGW2.png
Thank you
Do you have auto calculate on in the Office 365 Excel?
Check this article: https://support.office.com/en-ie/article/change-formula-recalculation-iteration-or-precision-f38c7793-0367-41ce-b892-dfe54946bd76#__toc305944076
I have been fooled in some vbs-script I've created for Excel , with calculation off as default for some Office 365 installations.
Check out formulars -> Calculation and check if everything is automatic on the workbook there.
Edit: Please note that I've zero experience with LibXL, but plenty in vbs for Excel. I also program c++, but I find vbs as a quicker way to get in goal for my projects :)
May this might help setting calculation on with
Calculation = xlCalculationAutomatic
then setting off when required with
Calculation = xlCalculationManual

MofComp Subscription not Working and Saved File Acting Strange

I am trying to register this file (mytest3.mof) :
#PRAGMA AUTORECOVER
#pragma namespace("\\\\.\\root\\subscription")
instance of __EventFilter as $EventFilter
{
Name = "Event Filter Instance Name";
EventNamespace = "Root\\Cimv2";
Query = "Select * From __InstanceCreationEvent Within 1 "
"Where TargetInstance Isa \"Cim_DirectoryContainsFile\" "
"and TargetInstance.GroupComponent=\"Win32_Directory.Name=\'C:\\\\test\'\"";
QueryLanguage = "WQL";
};
instance of ActiveScriptEventConsumer as $Consumer
{
Name = "TestConsumer";
ScriptingEngine = "VBScript";
ScriptFileName = "C:\\test\\test.vbs";
};
instance of __FilterToConsumerBinding
{
Filter = $EventFilter;
Consumer = $Consumer;
};
using the command PS C:\windows\system32\wbem> mofcomp mytest3.mof
And receiving this output :
Microsoft (R) MOF Compiler Version 6.2.9200.16398
Copyright (c) Microsoft Corp. 1997-2006. All rights reserved.
Parsing MOF file: mytest3.mof
MOF file has been successfully parsed
Storing data in the repository...
WARNING: File mytest3.mof does not contain #PRAGMA AUTORECOVER.
If the WMI repository is rebuilt in the future, the contents of this MOF file w
ill not be included in the new WMI repository.
To include this MOF file when the WMI Repository is automatically reconstructed
, place the #PRAGMA AUTORECOVER statement on the first line of the MOF file.
Done!
This has happened a few times now, and I can see that the event is not being registered.
Does anyone know why I am seeing the message about #PRAGMA AUTORECROVER? Youc an clearly see that this line has been included in the file, but the system still complains that it is not there ... I am not sure if this is part of the reason why the event is not being registered, but it seems like they may be related.
As an extra detail which may help to explain - when I save mytset3.mof in the wbem folder, the file cannot be found there until I enter the folder, create a new blank text file and save it as mytest3.mof. Until I do this (even though I have saved the document), the PC acts as if this file does not exist ... What is going on here? Could this be related to folder permissions?
It would appear that this issue is somehow being caused by Notepad++
When saving the file from Notepad++ I have to do the above process of creating a new blank file before it is made available to the system, and running mofcomp appears to do nothing (even though it says the data was saved to the repository) and complains about #PRAGMA AUTORECOVER.
After pasting the exact same file contents into a regular Notepad.exe instance and saving that, there are no issues whatsoever. The file is created after saving, and running mofcomp mytest4.mof not only returns a successful message in the terminal but I can also see that the event is now registered to monitor the C:\test folder.
Not quite sure what is happening with Notepad++ here but if anyone could shed some light that would be great!

C++ Write to file not working in my addition to an existing application

I have an application that collects heart rate data and displays in in a GUI. I don't want to change anything about how the application runs, but want to save the data into a .csv file to use with data manipulation programs. The program is called BluetoothGattHeartRate. I am running the sample code found here.
My addition to the code is just
std::fstream theDump;
theDump.open("path/to/file", std::fstream::out);
if (theDump.is_open())
{
theDump.write("ImHere", 6);
}
theDump.close();
inserted into the file called HeartRateService.cpp in the Shared directory in the void HeartRateService::Characteristic_ValueChanged(GattCharacteristic^ sender, GattValueChangedEventArgs^ args) function just before the call to ValueChangeCompleted(heartRateValue);. I'm using Microsoft Visual Studio to edit and run the code, as the tutorial online says. This exact code succeeds in editing the file when run in an independent application, but it fails to open the file (I tested for this) when run in the Gatt sample code.
I don't expect that anyone has dealt with this before, but if by some miracle one of you has figured this out, please let me know how you fixed it.

Excel 2013 access violation 0xC0000005

I have a problem with an old piece of software (early 2000) written in C++ that uses Excel for processing data. It worked fine in previous versions of Excel but since version 2013, I get a crash that I haven't seen before.
We have created our own COM add-in for Excel, this add-in is registered with regsvr32 and available in Excel 2013. The add-in refused to work at first but disabling Data Execution Prevention (DEP) got it working.
This add-in is accessed by creating an instance of Excel in code:
_Application.CreateDispatch ("Excel.Application");
After creating the instance of Excel we get the loaded add-ins from the instance and find our add-in by looping through the COM add-ins.
_Application.GetCOMAddIns();
Once we got our add-in we can send commands through the interface:
IExcelServer* server = excel.GetServerAddIn(); // Obtain the server COM-AddIn.
HRESULT result = server->Execute (&req, &rep, &retval);
One of the commands we can send here is requesting a value from Excel based on a given string label (the label will be in column A and this function returns the value in column B on the same row). Now the code crashes on the following line of code:
rng.Find (COleVariant (label), CovOptional, CovOptional, COleVariant (xlWhole), CovOptional, xlSearchNext, CovOptional, CovOptional, CovOptional);
The 'rng' object is of type Range and is from the correct sheet and the range goes from A1 to A17. When we get the value from 'rng' object (rng.GetValue2()) it gives us the following array (which contains the value that is specified in the label argument):
safearray of VARIANT = [1,17](Empty,Empty,BSTR = 0x160bc6bc "Web",Empty,Empty,Empty,Empty,BSTR = 0x0bbca5cc "Pre",BSTR = 0x15f499fc "WebStart",BSTR = 0x0bbca48c "WebMid",BSTR = 0x0bbca5a4 "WebEnd",BSTR = 0x160bc80c "Post",Empty,Empty,BSTR = 0x15f49a24 "SafeStartWeb",BSTR = 0x15f49a4c "SafeEndWeb",Empty)
We receive the following error while debugging:
"Unhandled Exception at 0x00ccbb4A in Excel.exe: 0xC0000005: Access violation reading location 0x00000000."
We also see the following message in the windows event viewer every time that Excel crashes:
"The description for Event ID 0 from source MSOIDSVC.EXE cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
InitializeSvcAPI failed with hr = 0x8004888d"
The code is made in VS2010 using C++ and running Windows7 x64. We have also tested the code on a Windows8 x64 machine but we got the same result.
Has someone seen this crash before or can advise how to fix it?
Thanks in advance.

Identifying a Programming Language

So I have a software program that for reasons that are beyond this post, I will not include but to put it simply, I'd like to "MOD" the original software. The program is launched from a Windows Application named ViaNet.exe with accompanying DLL files such as ViaNetDll.dll. The Application is given an argument such as ./Statup.cat. There is also a WatchDog process that uses the argument ./App.cat instead of the former.
I was able to locate a log file buried in my Windows/Temp folder for the ViaNet.exe Application. Looking at the log it identifies files such as:
./Utility/base32.atc:_Encode32 line 67
./Utilities.atc:MemFun_:Invoke line 347
./Utilities.atc:_ForEachProperty line 380
./Cluster/ClusterManager.atc:ClusterManager:GetClusterUpdates line 1286
./Cluster/ClusterManager.atc:ClusterManager:StopSync line 505
./Cluster/ClusterManager.atc:ConfigSynchronizer:Update line 1824
Going to those file locations reveal files by those names, but not ending with .atc but instead .cat. The log also indicates some sort of Class, Method and Line # but .cat files are in binary form.
Searching the program folder for any files with the extension .atc reveals three -- What I can assume are uncompiled .cat files -- files. Low and behold, once opened it's obviously some sort of source code -- with copyright headers, lol.
global ConfigFolder, WriteConfigFile, App, ReadConfigFile, CreateAssocArray;
local mgrs = null;
local email = CreateAssocArray( null);
local publicConfig = ReadConfigFile( App.configPath + "\\publicConfig.dat" );
if ( publicConfig != null )
{
mgrs = publicConfig.cluster.shared.clusterGroup[1].managers[1];
local emailInfo = publicConfig.cluster.shared.emailServer;
if (emailInfo != null)
{
if (emailInfo.serverName != "")
{
email.serverName = emailInfo.serverName;
}
if (emailInfo.serverEmailAddress != "")
{
email.serverEmailAddress = emailInfo.serverEmailAddress;
}
if (emailInfo.adminEmailAddress != null)
{
email.adminEmailAddress = emailInfo.adminEmailAddress;
}
}
}
if (mgrs != null)
{
WriteConfigFile( ConfigFolder + "ZoneInfo.dat", mgrs);
}
WriteConfigFile( ConfigFolder + "EmailInfo.dat", email);
So to end this as simply as possible, I'm trying to find out two things. #1 What Programming Language is this? and #2 Can the .cat be decompiled back to .atc. files? -- and vice versa. Looking at the log it would appear that the Application is decoding/decompiling the .cat files already to interpret them verses running them as bytecode/natively. Searching for .atc on Google results in AutoCAD. But looking at the results, shows it to be some sort of palette files, nothing source code related.
It would seem to me that if I can program in this unknown language, let alone, decompile the existing stuff, I might get lucky with modding the software. Thanks in advance for any help and I really really hope someone has an answer for me.
EDIT
So huge news people, I've made quite an interesting discovery. I downloaded a patch from the vendor, it contained a batch file that was executing ViaNet.exe Execute [Patch Script].atc. I quickly discovered that you can use Execute to run both .atc and .cat files equally, same as with no argument. Once knowing this I assumed that there must be various arguments you can try, well after a random stroke of luck, there is one. That being Compile [Script].atc. This argument will compile also any .atc file to .cat. I've compiled the above script for comparison: http://pastebin.com/rg2YM8Q9
So I guess the goal now is to determine if it's possible to decompile said script. So I took a step further and was successful at obtaining C++ pseudo code from the ViaNet.exe and ViaNetDll.dll binaries, this has shed tons of understanding on the proprietary language and it's API they use. From what I can tell each execution is decompiled first then ran thru the interpreter. They also have nicknamed their language ATCL, still no idea what it stands for. While searching the API, I found several debug methods with names like ExecuteFile, ExecuteString, CompileFile, CompileString, InspectFunction and finally DumpObjCode. With the DumpObjCode method I'm able to perform some sort of dump of script files. Dump file for above script: http://pastebin.com/PuCCVMPf
I hope someone can help me find a pattern with the progress I made. I'm trying my best to go over the pseudo code but I don't know C++, so I'm having a really hard time understanding the code. I've tried to seperate what I can identify as being the compile script subroutines but I'm not certain: http://pastebin.com/pwfFCDQa
If someone can give me an idea of what this code snippet is doing and if it looks like I'm on the right path, I'd appreciate it. Thank you in advanced.