The plus sign is deleted when importing to the xls file - laravel

Laravel version 5.4
Expected behaviour
Actual behaviour
Steps to reproduce the behaviour
$sheet->setColumnFormat(array(
'A' => '#'
));
foreach ($order_details as $key => $detail) {
$sheet->appendRow([(string)$detail->model->id_supplier, $detail->model->mintitle, $detail->qty, $detail->price, $detail->qty * $detail->price,]);
$sheet->setHeight($sheet->getHighestRow(), 45);
}
How to import a number with a plus sign?

if that is microsoft excel, or some similar app; then it is not in your code, excel treats the +digit as a positive digit, and hence it removes the +, happens with the zeroes as well, try to include '' wrapper around your value to convert it to string and to prevent excel from doing so.

It happens because the number you expect was a positive digit(+49983), if you reproduce the number with + sign, it removes + sign while displaying in excel.,
To check open a new excel and try to add +49983 and move to next column, the + will automatically gone, because of the positive digit.

Related

How to disallow repeated numbers in telephone field like 1111111 or 222222

I am using contact form 7 and want to disallow users to enter repeated numbers like 1111111 or 2222222 in phone field.
I am using below code to enter only 10 digits. Can anyone help me with what I should change or add in this to work.
// define the wpcf7_is_tel callback<br>
function custom_filter_wpcf7_is_tel( $result, $tel ) {<br>
$result = preg_match( '/^\(?\+?([0-9]{0})?\)?[-\. ]?(\d{10})$/', $tel );<br>
return $result; <br>
}<br>
add_filter( 'wpcf7_is_tel', 'custom_filter_wpcf7_is_tel', 10, 2 );
First of all, [0-9]{0} looks like a typo as this pattern matches nothing, an empty string. You probably wanted to match an optional area code, three digits. So, use \d{3} if you meant that.
Next, to disallow same digits within those you match with \d{10}, you simply need to re-write it as (?!(\d)\1{9})\d{10}.
Bearing in mind what was said above, the solution is
function custom_filter_wpcf7_is_tel( $result, $tel ) {<br>
return preg_match('/^\(?\+?(?:\d{3})?\)?[-. ]?(?!(\d)\1{9})\d{10}$/', $tel );<br>
}
See the regex demo.

JDBC Import into sheets, how to keep leading zeros on fields?

I have so much trouble with leading zeros in general. Importing into Sheets using JDBC connection, I haven't figured out a way to keep the zeros. The column types are varchar() for values of varied length, and char() for static length.
In the past with other data I have added a leading ' to values, or chosen to getDisplayValue() to keep them. What would work here?
while (results.next()){
var tmpArr = [];
var rowString = '';
for (var col = 0; col < numCols; col++) {
rowString += results.getString(col + 1) + '\t';
tmpArr.push(results.getString(col + 1));
}
valArr.push(tmpArr);
}
sheet.getRange(3, 1 , valArr.length, numCols).setValues(valArr);
Data Exmaple varchar column:
0110205361
0201206352
140875852
LFCP01367
LGLM00017
You are retrieving data into a Google Sheet from a MySQL database table using Jdbc. One of the database columns is formatted as "varchar" and includes some all-numeric values that have one or more leading zeros. When you update the database values to your Google Sheet, the leading zeros are not displayed.
Why
The reason for this is that the all-numeric values are displayed without the leading zeros is that the cells are formatted as Number, Automatic (or otherwise as a number). This means that they are 'interpreted' by Google Sheets as a number and, by default, all leading zeros are dropped.
On the other hand, if the cells are formatted as Number, Plain Text, then the all-numeric values are 'interpreted' as strings, and any leading zeros are retained.
The effect of formatting can be clearly seen in the following images, which also include istext and isnumber formula to confirm how they are interpreted under each format type.
Formatted as Number - Plain Text - treated as strings
Formatted as Number - Automatic - treated as numbers
Formatting on the fly
An alternative to pre-formatting (which wasn't successful in the OP's case) is to set the format as a part of the setValues() method using setNumberFormat
For example:
sheet.getRange(3, 1 , valArr.length, numCols).setNumberFormat('#STRING#').setValues(valArr);
There is a useful discussion of this methid in Format a Google Sheets cell in plaintext via Apps Script

Visual Studio 2012 Form1.vb user input validation

I have connected the sql database to my vb project and the last feature I need is to validate the user input. Two of the textboxes needs to be validated when adding a new record.
txtName is the first textbox that consists of the following format: BCO103/T1/01 . 'BCO' will always stays the same, however the rest needs to be input by the user. Letters and numbers needs to stay in exact the same place.
txtModuleID is the second textbox that needs to be validated. The data for this field looks like this: BCO120 . Yet again, BCO will always stay the same, however the 3-digit number will change.
Im sure you can use substrings for this
for example:
If txtModuleID.Text.Substring(0,2) = "BCO" And txtModuleID.Text.Substring... etc Then 'add other conditionals
blnValidated = True
Else
blnValidated = False
End If
If txtModuleID.Text.Trim.ToUpper().SubString(0,2).equals("BCO") and len(txtModuleID.Text.Trim) = 6 Then
If txtModuleID.Text.Trim.SubString(3,5).isNumeric() Then
//valid input
Else
//message prompt that last 3 digits of the input is not numeric
End If
Else
//message prompt that input has invalid format and that input must start with BCO
End IF
Substring (0, 2) means from 0 until 2... getting the sub string of the input with letters in index 0, 1 and 2. The rest follows.
As for the first input, please do expound. I didn't quite catch how you want it to be validated.

How do I keep a certain number of digits in a double in Visual Basic

I am trying to display a double so it will always have 4 digits after the decimal point. For example, one double would be 0.0182, and another 0.0180. However, my problem occurs when the double ends in 0, which results in truncating the zero and leaving 0.018. I'm trying to add on a zero at the end of my number to fix this, but receiving a syntax error.
Dim minFeature As Double
...
minFeature = Round(minFeature, 4) ' keep only 4 digits of precision. works.
minFeature = CDbl(CStr(minFeature).PadRight(1, "0")) ' add on an extra 0. does not work.
This will return the number as a string and preserve four decimal places.
Format(minFeature, "0.0000")
For more information, see the docs on Format().

How to solve invalid parameter error using Codeigniter and Pesapal

Am trying to test my payment module using codeigniter and pesapal but I keep getting this error "Problem: parameter_rejected | Advice: invalid_value_for_amount> oauth_parameters_rejected | Ksh.4%2C999".
Where Ksh. 4%2C999 is the bill ksh. 4999. I have used the right Pesapal keys so I don't know what am doing wrong.
Problem
Your amount has a thousand separator ... something like this Ksh.4,999 instead of passing a value that's an integer like 4999.
Either you are passing in the amount with the comma (which you can fix by removing the comma in your logic) or the number_format() method is adding the thousand separator (explanation given below in solution).
Solution
According to the PHP docs number_format() does something like this (basic case only)...
// english notation (default)
$english_format_number = number_format($number);
// 1,235
Note how it's added a , as the thousand separator. This is what is being converted(encoded) to %2C. Pesapal doesn't understand numbers with the , which is what you are passing to them. ... to stop the function from using the thousands operator do something like this ...
// english notation without thousands separator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57
3rd parameter specifies the decimal separator (which is .) and the 4th specifies the thousand separator (which is an empty string).
But as #BabyAzerty has said, without code there's nothing much that we can work with to assist you. I'll amend the answer the more context you give to your problem but the above is pretty much what I've seen wrong with your implementation elaborated in the question and comment above.
$amount1 = (integer)$data->amount;
$amount = number_format($amount1, 2, '.', '');//format amount to 2 decimal places
$desc = $data->phone_type;
$type = "MERCHANT"; //default value = MERCHANT
$reference = $data->reference;//unique order id of the transaction, generated by merchant
$first_name = $data->name1;
$last_name = $data->name2;
$email = $data->email;
$phonenumber = $data->mobile;//ONE of email or phonenumber is required
This error means that your account on Pesapal has a limit on the amount it can transact. By default the amount is usually set to USD 10 or the equivalent of it in local currency.
You need to contact the team at support.pesapal.com to complete your sign-up by submitting contract and documents for your business in order to have the account activate for full transactions.

Resources