我正在尝试在格式中添加一个空格,但是当我运行此选择时,它不会添加像这样的空间A#A#A#有人可以帮助我吗?
UPPER(SUBSTRING(REPLACE(CONVERT(NVARCHAR, DECRYPTBYKEY(postal_code)), '-', ''),0, Len(REPLACE(CONVERT(INT, DECRYPTBYKEY(postal_code)), '-', '')-2)) + ' ' + SUBSTRING(REPLACE(CONVERT(NVARCHAR, DECRYPTBYKEY(postal_code)), '-', ''), Len(REPLACE(CONVERT(INT, DECRYPTBYKEY(postal_code)), '-', '')-2), Len(REPLACE(CONVERT(INT, DECRYPTBYKEY(postal_code)), '-', '')))) as [Postal Code],
目前我在字段A#A-#A#,a#a#a#,A#A#A#,a#a#a#,a#a-#a#
中有这些格式实施例: B1P5T9 B1A 3G4 B1P2R4 B1L1A2 B1P4L9 B1Y 3B7 B1P 1H6 B1L 1G9
答案 0 :(得分:0)
我尝试这样的事情:
select case
when charindex(' ', postal_code) = 4
and len(postal_code) = 7 then postal_code
when charindex(' ', postal_code) = 0 and len(postal_code) = 6
then left(postal_code, 3) + ' ' + right(postal_code, 5)
etc
else default value
end formattedPostalCode
from etc
where it's Canadian
答案 1 :(得分:0)
修正了此问题,无论您是否有空格或短划线,此代码均可正常运行。只在需要时添加空间。使用上面列出的任何格式也将全部置于大写。
$x=1;
while ($x<=5){
if($sheet->getCell('A'.$x)->getValue()=="1")
{
$sheet->SetCellValue('B'.$x, 'Something');
$x++;//Increment here?
}
$x++;//orIncrement here?
}