Powerbuilder exporting to Excel R1C1 localization issue - excel

So I got an OleObject excel.application... and I am exporting data from the application into excel. I am using PowerBuilder 11.5. So in the excel I got Summary fields which I program setting formulas, like aole_handle.Selection.FormulaR1C1 = "=RC[1]/RC[-1]". In my case it works well. Now I send the application to the testers that are in German. They tell me that they got this message "Error calling external property in function..." when the row reaches to set the Formula. We even tried just to read the formula from that cell, like: string ss ss = aole_handle.Selection.FormulaR1C1 and it also craches... So the question is what would be the problem... I use Microsoft Office 2010 EN, testers use the German version... if the problem is this, then how would it be it good to solve it, so the application would work independently of the office language? I have tried also:
aole_handle.Selection.FormulaR1C1("=RC[1]/RC[-1]")
aole_handle.Selection.Formula("=RC[1]/RC[-1]")
aole_handle.Selection.Formula = "=RC[1]/RC[-1]"

Excel formulae are localized when given via OLE connections, thus when you have a formula like =SUM(...) on a French localized host you would have to send =SOMME(...) and with a German host =SUMME(...) or you get an error when setting the formula.
Similarly, the R1C1 notation needs to be given as Z1S1 in German. I have no German localized Excel to check, but I would suggest to test for a formula like =ZS[1]/ZS[-1]
Yes, this is a very annoying issue when you need to deal with foreign localized host to handle different formulae depending on the language.

Related

Microsoft Excel keeps repairing my .xlsm file for no apparent reason and eliminates data validations on a sheet

I recently created an automated Excel utility (using Microsoft Office 2019), in which I've extensively used data validations, VBA code, named ranges and formatting. It was working well until one day I received an Excel prompt message that read:
When I click on Yes, it gives me another pop-up where it says it recovered the file, and also gives me a link to the error log XML file. I click on it and open the .xml file using my default browser, and it shows the following details:
Looks like it is removing data validations from a particular sheet, and I realize that is true when I navigate to that sheet in the UI. To work around this unwarranted and repeated data-validation removal that Excel application is enforcing, I created a macro code that will re-instate all these data validations as required. The real problem arises when this Excel file is opened on a different computer with Microsoft Office 365. Looks like it is removing not just data-validations but also other components like named ranges and buttons. There could be other things that it might be removing, which I am unaware of at the moment. So the macro created to re-instate the data-validations is no longer useful.
Why does this problem arise? And why is different version of Excel behaving differently? How do I solve this? Appreciate your kind help. Thank you!
As rightly suggested by Ron Rosenfeld and e_conomics, the issue was with the data validation lists, whose sources were strings of comma separated values that were going beyond 255 characters. Apparently, that is a limitation with Excel.
When I replaced the sources of data validation lists (string of comma separated values) with the ranges containing the corresponding values, the problem resolved itself. The repair dialogue never appeared again.

An issue when generating text with national symbols using VBA in Excel 2019

I am using some VBA add-in to generate text from numbers, that text contains national Lithuanian, German or any other national symbols. This used to work fine with the previous versions of Excel so far, but the system has now been upgraded from scratch and it does not seem to work well with Excel 2019.
In VBA, the code looks fine and you can see the national symbols like "š" (well after setting the locale to Lithuanian, before they were appearing as multiple strange symbols):
, however when in excel the functional is called, the output has just � instead of any national symbol. All of the national symbols are marked with the same � sign in Excel 2019. But you can write manually national symbols just fine in Excel, just what comes out of VBA is garbage missing those symbols.
It looks like this in a cell:
Trys �imtai �, 00 ct
Does anybody know how to fix this and make them appear normal with how they are visible within the code?
A few other observations are that when copying and pasting the code from the VBA Editor to Notepad++ the national symbols get lost as well and they appear as different strange symbols. Also when trying to use the find function in the VBA Editor window to find anything with the national symbols - no results are ever found as long as you don't remove the national symbols...
In my understanding, support for "international" ("non-Latin") characters is determined by your Windows Regional Settings, not by Excel or by the VBA IDE.
Since I'm in Canada I can't easily test on my end to verify this, but interestingly, your example character of š displays the opposite of how it shows for you: it renders properly on the worksheet but as gibberish in VBA.
Incidentally I determined the Unicode id number for š (Unicode 353) by pasting the symbol into cell A1 and then in another cell using formula =UNICODE(A1). The opposite function (to return a character from it's code) is UNICHAR. The VBA equivalents are AscW and ChrW.
I was aware that the VBA IDE can be made to display "international" characters by adjusting Windows Regional Settings (like discussed here), but I didn't realize any setup would make them not render on the spreadsheet since for me, most Unicode characters display properly on a worksheet.
I assume the characters don't work for you in other applications besides Excel. If that's not the case, and this problem is specific to Excel (or if you can't otherwise get it figured out by adjusting Windows Regional Settings), then I'd suggest contacting Microsoft Tech Support.
More information is here or here or in this search might also be helpful.
hi i had same problem in latvian
just uncheck utf - 8 beta in regional language settings for non unicode
enter image description here

Name of Excel formula in different languages in xlsx format

I generated Excel file in my application in xlsx format. Unfortunately if I use English name of the function and my Excel is not set to English then Excel identifies it as bad function name. Simillar situation does not happen in xls format.
Is it any way to avoid this problem?
Configuration of Excel itself is not acceptable solution as client should not be forced to make changes in his environment.
Thanks in advance for any help
Excel has its own way for translating the formulas from every language to English. You should not take care of that, it does it quite well. Thus a file in Spanish Excel can be read in French Excel without further adjustments.
E.g., see the German formula "SUMME" in F1. It is translated by excel to "SUM", when you ask about it -> see the immediate window on the right.
The only thing you should avoid is formula like this:
activecell.FormulaR1C1Local= "=SUMME(Z(8)S(-2):Z(9)S(-2))", because it takes the local formula as a string and Excel cannot find a way to translate "SUMME" to "SUM".

Why does the string format returned by Range.Address(external:=True) change?

I have some VBA code that obtains Excel cell references as a string using
rng.Address(External:=True, ReferenceStyle:=xlR1C1)
The VBA code talks to a COM server, which needs to know what the string format is.
Unfortunately, the format seems to switch (at random?) between two cases. I don't know what is causing VBA to make this change.
The two formats are
'[book]sheet'!R1C1
[book]sheet!R1C1
That is, sometimes the book-and-sheet part has enclosing single quotes but sometimes it doesn't!
I can see these format changes within the VBA debug window by directly printing the address string.
I have experienced this on Office 2007 and 2010.

Excel formulas are not being generated by Reporting Services

I'm working on a report for my employer where the end product is a SSRS report, but one that will almost ALWAYS be exported to Excel for further manipulation. In this report, there is a row that is really just a row of calculations based on other cell values.
I've read that Reporting Services can "figure out" Excel formulas, and will generate and insert them where it can so long as your expressions for the cell's value do not contain database field references, only report item references.
Well, I've done this and I'm still not able to get the formulas to come through. I've tried rendering the report every way I could think of, and I've tried modifying the DeviceInfo parameters to include the OmitFormulas option set to False, and still I've come up empty. I've even tried creating a VERY simply table based report with hard-coded values, and even then I don't get formulas.
Here's a sample expression from my report:
=(ReportItems!Balance2.Value + ReportItems!Supply3.Value) - ReportItems!Demand3.Value
My environment is VS 2008 (fully patched/updated) running on SSRS 2008 (not fully patched). I've talked to the server admin, and he says it's running CU1 (I think, can't remember for sure). Our company's Excel is version 2007.
I'm really at my wits end here, so I'm hoping someone out there has dealt with this before and can give me an answer. Thanks!
I have also tried this, the problem here is that SSRS 2008 simply does not support this functionality. It is true that in earlier versions of SSRS it was somewhat supported (2005), however they took that out in the later versions... too bad..
see link:
http://social.msdn.microsoft.com/Forums/en/sqlreportingservices/thread/ddf2f19d-3f70-4bb0-a035-00709ffee2f9
I found a way to do it IF you know the cell addresses, though it's a bit of a hack. In your report, enter the cell formula as a string preceded by an apostrophe, the "this is text" escape character in Excel:
="'=A2+A3"
When you export into Excel the apostrophe will be invisible, but the formula appears as text:
=A2+A3
Now if you do a find/replace and remove the apostrophes (replace with nothing), the formulas will calculate correctly.
SSRS has quite a few limitations when it comes to Excel content. As you mentioned Excel Formulas or even charts for example are rendered as images instead of Excel Charts.
Seeing as you mentioned that you want a report that works in SSRS, but will always be exported to Excel you should really checkout OfficeWriter at http://www.officewriter.com/.
OfficeWriter can integrate with SSRS and will allow you to export a full fidelity Excel document. By that I mean you can have Excel Formulas, not the rendered SSRS formulas, or real Excel charts not the rendered image. These types of things won’t change if your data changes after the file have been rendered and opened by SSRS.
If the “further manipulation” happens by end users then this is great, they can change numbers and the formulas will recalculate and the charts will update.
If the “further manipulation” is programmatic, then you can use OfficeWriters API to continue to manipulate the document.
You may want to give it a look, I hate for you to be on your wits end.
DISCLAIMER: I am one of the developers on OfficeWriter.

Resources