perl Excel::Writer::XLSX write_formula encoding - excel

I am trying to use Excel::Writer::XLSX. Most things already successfully, but I struggle to get a formula into a cell.
use utf8;
is set
I am trying to set the formula into the cell with the following statement:
$av_obj_excel_worksheet_DATA->write_formula( 'a3', '=_xlfn._xlws.FILTER(gw_col_gwuPMBo,(MONTH(gw_col_DATUM)=1)*(gw_col_gwuPMBo<>0),"_empty")' );
I have the extracted the .xlsx-file (since it is a simple zip-file) and had a look at the relevant xml of the spreadsheet.
The result is:
_xlfn._xlws.FILTER(gw_col_gwuPMBo,(MONTH(gw_col_DATUM)=1)*(gw_col_gwuPMBo&lt;&gt;0),"_empty")
but the result should be, since I created an .xlsx-file manually and had again a look at the relevant xml-file of the relevant spreadsheet:
_xlfn._xlws.FILTER(gw_col_gwuPMBo,(MONTH(gw_col_DATUM)=2)*(gw_col_gwuPMBo<>0),"_empty")
I seems to me some unicode problem.
Unicode is difficult to understand and - I regret - I don't realy do!
Can someone help me what to do to get the correct form of the formula into the .xlsx file (or related .xml-file of the relevant spreadsheet?
Thanks

I already experimented with encode and decode and now found the solution:
$av_tmp_STRING = '=_xlfn._xlws.FILTER(gw_col_gwuPMBo,(MONTH(gw_col_DATUM)=1)*(gw_col_gwuPMBo<>0),"_empty")';
$av_tmp_STRING = decode( 'UTF-8', $av_tmp_STRING );
$av_obj_excel_worksheet_DATA->write_formula( 'a3', $av_tmp_STRING );
the hurdle was that I did not see the result durging debugging the script. But the correct string was written to the .xlsx-file.
Sometimes, by thinking, searching and trying it comes to a positive result.

Related

String Foramting vb.net

i want to display date value like '2020/03/30' as '20200330'
i tried this code
Date.Now.Year & Date.Now.Month & Date.Now.day
but this returns 2020330
how can this return 20200330 ??
You are concatenating numbers, which get implicitly converted to strings.
You could check out Custom date and time format strings.
In your case, this might do just fine: Date.Now.ToString("yyyyMMdd")
By the way, as #jmcilhinney already commented to your question, you could easily find such basic information by using your favorite search engine on the internet...

Questions regarding Python replace specific texts

I'm writing a script to scrape from another website with Python, and I am facing this question that I have yet to figure out a method to resolve it.
So say I have set to replace this particular string with something else.
word_replace_1 = 'dv'
namelist = soup.title.string.replace(word_replace_1,'11dv')
The script works fine, when the titles are dv234,dv123 etc.
The output will be 11dv234, 11dv123.
However if the titles are, dv234, mixed with dvab123, even though I did not set dvab to be replaced with anything, the script is going to replace it to 11dvab123. What should I do here?
Also, if the title is a combination of alphabits,numbers and Korean characters, say DAV123ㄱㄴㄷ,
how exactly should I make it to only spitting out DAV123, and adding - in between alphabits and numbers?
Python - making a function that would add "-" between letters
This gives me the idea to add - in between all characters, but is there a method to add - between character and number?
the only way atm I can think of is creating a table of replacing them, for example something like this
word_replace_3 = 'a1'
word_replace_4 = 'a2'
.......
and then print them out as
namelist3 = soup.title.string.replace(word_replace_3,'a-1').replace(word_replace_4,'a-2')
This is just slow and not efficient. What would be the best method to resolve this?
Thanks.

How to fix "StringConverter cannot convert from System.Double." in In\\UiPath

When I make the "Read Cell" in "Excel application scope", I tried to output the read data from Excel by using "Write Line". However, It's not working and it ouput the error as in the Title. Could you someone make it up?
I had the same issue. I'm using the LookupDataTable activity. In my Excel file I have a mix of Strings and Integers. But somehow I also got the error:
NotSupportedException: StringConverter cannot convert from
System.Double.
I solved it by changing the variable from String to GenericValue.
I also tried to give it the Double type, but it didn't work because I think I have different types in the column.
Try this maybe be it will help you to check out
Convert.todouble

Trying to write an IF ( Match ); possible syntax error?

Highly likely this is a syntax error, but it's not throwing any errors.
=IF(ISERROR(MATCH(MID(Z2,28,6),$AF$1:$AG1,0)),"Mismatch","Included")
I have Z2, Z2 contains the following text:
"Revenue account for invoice P13930."
Or something like that, so the Mid function is suppoused to match that code, P13930, and not if it is within the specified cells (Here, AF1 and AG1)
I tried copying the whole text, or even just the code to AF1 and AG1, but it never writes a match. What's wrong with it?
Based it on my prototype:
=IF(ISERROR(MATCH($AE1,$AF1:$AG$1,0)),"Mismatch","Included")
Which does happen to work.
EDIT: I forgot to mention, I was wondering how to include the following scenarios:
Sometimes the code would look like this: P13930. and other times like this: P13930A. I'm not sure how to consider these as my knowledge is limited to Mid , Left , and Right. And as Jordan Mentioned, MATCH would be out of the picture given these variations.
If AF1 and AG1 contain codes like P13930A, you can use a wild card to match them like this
=IF(ISERROR(MATCH(MID(Z2,29,6)&"*",$AF$1:$AG1,0)),"Mismatch","Included")
Could you please specify your question:
First which we can advice, is to correct mid function argument:
=IF(ISERROR(MATCH(MID(Z2,29,6),$AF$1:$AG1,0)),"Mismatch","Included")
MID(Z2,29,6) - will give you result P13930
and then you want to find this code in some area, don't you? for example in the area AF1:AG1.
Please specify the result which you want to see in the cell AF2:
(a) code P13930; (b) INCLUDED - if area AF1:AG1 includes code P13930; (c) MISMATCHED - if area AF1:AG1 does NOT include code P13930 and etc.

Getting the result of an excel formula in python

I need to open a .xlsx-file (without writing to it) in python, to change some fields and get the output after the formulas in some fields were calculated; I only know the input fields, the output field and the name of the sheet.
To write some code: Here is how it would look like if I would have created the library
file = excel.open("some_file.xlsx")
sheet = file[sheet_name]
for k, v in input_fields.items():
sheet[k] = v
file.do_calculations()
print(sheet[output_field])
Is there an easy way to do this? Wich library should I use to get the result of the formulas after providing new values for some fields?
Is there a better way than using something like pyoo, maybe something that doesn't require another application (a python library is clearly better) to be installed?
I'll just thank you in advance.
I now came up with a (very ugly) solution.
I am now reading the xml within the xlsx-file, and I am now using eval and some regular expressions to find out wich fields are needed; and I have defined some functions to run the calculations.
It works, but it would be great if there were a better solution.
If the resulting library is ready, and I don't forget to do this; I'll add a link to the library (that'll be hosted on Github) to this answer to my own question.

Resources