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
Related
In my application a user can have multiple documents open and print all documents to PDF's using a "Microsoft print to pdf" option when they are prompted at the print dialog window, after which they choose the destination folder. Now what happens is that if there are 30 documents selected for print, an inconsistent amount are successfully printed to pdf in the desired folder each time it is run. Sometimes all are successful and other times not. I found that files with unicode character names like this "敥敥敥敥敥敥敥敥" where being created in the same directory as the file of code that contains this print to pdf process. I can rename these files with a ".pdf" extension and they are working pdf documents.
Here is the part of code concerned:
DOCINFO docInfo;
memset(&docInfo, 0, sizeof(docInfo));
docInfo.cbSize = sizeof(docInfo);
docInfo.lpszDocName = csPlanoName;
docInfo.lpszOutput = csOutputDir + csPlanoName + csExtension;
if(dc.StartDoc(&docInfo) > 0) {
//printing process continues
}
I found that by stepping through the code, the StartDoc function call would change docInfo.lpszOutput to the same unicode characters "敥敥敥敥敥敥敥敥". This would not happen all the time, and does not happen with specific files when testing. One test a document will print to pdf successfully, another test with the same document and it will create the file with the name "敥敥敥敥敥敥敥敥".
Any help with this would be greatly appreciated.
Regards,
Chris
What are csPlanoName csOutputDir? docInfo.lpszDocName and docInfo.lpszOutput must be pointers to null-terminated strings and since you are using csOutputDir + csPlanoName + csExtension that won't work with regular pointers something else might be happening here. Make sure that result of csOutputDir + csPlanoName + csExtension is not getting implicitly cast to pointer and then going out of scope.
using a string conversion macro seems to have solved my problem, successfully tested outcome 10+ times.
CString csFullpath = csOutputDir + csPlanoName + csExtension;
docInfo.lpszOutput = CT2W(csFullpath);
I'd like to embed R into a c++ winforms app. It will output the graphs to a pictureBox, and output the numbers to a richTextBox. It takes commands from a textbox. I tried the header file RInside.h, but there is no such file.
Pseudo code:
#include <someDirToImbedR>
ExecuteButton_Click(args) {
RExecute(commandTextBox->Text);
outputGraphPictureBox->Load(output_graph);
richTextBox1->Text = OutputString;
}
I found this post on SO concerning (may be) the same problem.
Here is the Link to a repository by Dirk Eddelbuettel. It has even sample code in c++ to try for yourself.
Also this Link might be helpful.
Hope this can bring you on track. Unfortunately I personally used R only in C#.
I am running libsvm through weka. Its output accuracy looks good to me, so I am planning to write a svm model by myself. However, weka didn't generate any training parameter, such as number of support vector. Therefore i cannot do anything. Searching the web, i found somebody said it would generate some parameters like the following:
optimization finished, #iter = 27
nu = 0.058475864943863545
obj = -1.871013102744184, rho = -0.19357337828800944
nSV = 9, nBSV = 0 `enter code here`
Total nSV = 9
but how come i didn't see any of them? any step that i missed? please help me. Thanks a lot.
Weka writes the output you mentioned to stderr.
So if you have started weka.sh or weka.bat from a terminal (or "command window" if you are on Windows), you should see that output appear in your terminal window after clicking "classify"
If you want to have access to this information via scripts, you can
redirect the output to a file and read in that file.
Here is how to edit the startup file weka.sh / weka.bat.
Edit this line (it is probably the last line) in order to write log info to a file instead of the terminal window:
java -cp $CP -Xmx8092m weka.gui.GUIChooser 2>>/opt/weka-stable/weka.log &
You can also add a properties file to your home directory to add more fine-grained behaviour.
https://weka.wikispaces.com/Properties+file
(You probably can also access information via the Weka Java API somehow, but you did not ask for that)
I am trying to implement this person's code: http://iris.lib.neu.edu/civil_eng_theses/30/ but I can not generate a working executable in visual studio because I am missing 2 files: myoutput.cpp and PrintTimeReferencedVariable.cpp. I am unclear if the Matlab builder is supposed to generate them or I write them.
The myoutput.cpp is supposed to be a C++ file that does essentially a dlmwrite. It is used as follows:
function [] = Output_01(FileName, FileNameLenght, OutputData, OutputSize1, OutputSize2)
coder.inline('never')
coder.ceval( 'myoutput', FileName, FileNameLenght, OutputData, OutputSize1, OutputSize2);
end
% %% Matlab Version: to run the model in Matlab uncomment below, comment above
% function [] = Output_01(FileName, FileNameLenght, OutputData, OutputSize1, OutputSize2)
% dlmwrite(FileName, OutputData,'-append','coffset',0,'delimiter','\t','precision','%6.6G')
% precision = 4;
% disp( num2str( OutputData,precision))
% end
Where the commented out is the matlab version of the file and the top is what is built into C++. The files are supposed to write to the directory: C:\matlab-results-from-cpp.
The PrintTimeReferencedVariable.cpp looks like a date function that should do:
% Date = datestr(now, 'yyyy-mm-dd-HH-MM-SS' );
%% Matlab Version: to run the model in Matlab uncomment above, comment below
Date = '2012-09-16-09-19-20';
coder.ceval('PrintTimeReferencedVariable', coder.wref(Date));
Any insight into this would be much help. I'm still waiting to hear back from the author but it would still be helpful to hear all of your input as this is my first time in C++ and building projects in Matlab.
Thanks!
Seems like the text is pretty clear on what you do, though I can understand the confusion not coming from a C++ background:
5)
“Project Settings ”adjustments: Open ‘More settings’,then in ‘All Settings’ tab, choose for ‘Language’ C ++; In “Speed” tab mark only “Saturate on integer overflow”, unmark everything else; in “Custom Code ” tab, copy and paste the first lines the functions “myoutput.cpp” and “PrintTimeReferencedVariable.cpp”, followed by semicolon or see below the text:
void PrintTimeReferencedVariable (char * DateOut);
void myoutput(const char* _filename, int fileNameLen, double* data, int n, int m);
So you create the files "myoutput.cpp" and "PrintTimeReferencedVariable.cpp". Copy and paste the code into the respective cpp files. Then add the prototype(the second quote) to your header or at the top of those files.
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