-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String formatting #64
Comments
Thanks for reporting this. I've been thinking about adding a switch I'd have thought your workaround would have solved the problem. You might want to try to prepend a single quote to the data I'm not sure why this worked for me.
|
Thank you for the reply Doug. I tried your code but PowerShell complains: New-PSItem : The term 'New-PSItem' is not recognized as the name of a cmdlet, function, script file, or operable program. |
Do you have the latest version of the module? |
You are correct, I wasn't using the latest version. Just updated and tried this: $File = 'S:\Test\Out_Test\List.xlsx'
rm $File -ErrorAction Ignore
$Users = Get-ADUser -SearchBase 'OU=Users,DC=domain,DC=net' -Filter * -Properties MobilePhone
$Users | Select SamAccountName ,MobilePhone, @{l='tel';E={New-PSItem $_.MobilePhone}} | Export-Excel $File But then I get this error: Cannot find an overload for "tryparse" and the argument count: "2".
At S:\Test\Input_Test\ImportExcel\Export-Excel.ps1:167 char:24 I'm probably missing something obvious here, but the help of Also, when I try this: $File = 'S:\Test\Out_Test\List.xlsx'
rm $File -ErrorAction Ignore
$(
New-PSItem '+32 4 4444 444'
New-PSItem '+32 4 4444 445'
) | Export-Excel $File This is only on the server, when testing the last example on my Win 7 workstation I does keep the '+' signs. So it might be region related. |
Sorry, I wasn't clear. The What OS is the server? Can you find out what version of .NET is installed there too? In your original example, can you add a |
I cannot repro this in my environment. Hard to pin down. You may have tried this. If you create the spreadsheet on the server and then open the file on Windows 7, what result do you get? Thanks for going through all of this. |
No problem Doug, I already appreciate you looking into this. I've always opened the file from the Windows 7 workstation, as I don't have an Excel installation on the server. This means that the results would be the same as previously reported. Can it be due to the .NET differences? |
Yeah, it looks like it is coming down to the .NET versions, but don't know if it is the root cause. The underlying mechanism this is layered on used the Microsoft Office .NET framework to read/write the Excel file. An update from .NET 4.0 to 4.5 could definitely make the difference. If is very much suspect since it works on the 4.5 .NET box. |
Couldn't figure it out. Tried updating the .NET version and other stuff, no success until now :) The problem lies within if([double]::tryparse($cellValue, [ref]$r)) {
$targetCell.Value = $r
} else {
$targetCell.Value = $cellValue
} On my Win Srv 2012 it goes to '+32 4 4444 444' | Export-Excel $file -show Better test: $Test = '+32 4 4444 444'
[Double]::TryParse($Test, [ref]$null) Result: This appears to be related to the Get-Culture
LCID Name DisplayName
---- ---- -----------
2067 nl-BE Dutch (Belgium)
Get-UICulture
LCID Name DisplayName
---- ---- -----------
1033 en-US English (United States) Does this give you a clue? Why is it evaluating a |
Thanks for drilling down on this.
|
Can you please try this on the server and post the results?
Here are mine:
|
Same result as you, both on server and on client: Value Result
----- ------
1.2 True
1 True
a False
-31 True
+32 44 False
+32 4 4444 444 False So this |
Thanks for trying that. This looks like good news. How difficult would it be for you to update the module after I implement? What day this week would be good for you? I'd update in GitHub first so you'd need to grab it there. |
You're welcome Doug! Strange that I'm the only one experiencing this issue but I'm glad we (you) finally figured it out :) I would really like to update to the new version, the only modifications I made myself are:
If these two fixes and the one from this tread could make it into the production branch I can update our old module without worries. And then there's no need for me anymore to be out of sync with your repository. Thank you in any case for the great job you did and still do on this awesome module! |
Thank you, couldn't have done it without you. The problem looks solved, but don't know why it is happening. The two modifications you made, I have not addressed in the module. Plus, I've added new features like conditional formatting. I'm going to add the |
OK, I pushed that change as well as other feature updates. If you try it, let me know if you have issues. I don't have a time frame for when I can get to the -Raw or the UNC. I punted on the UNC because I believe there is a a work around using the ProviderPath when you pass it to the function. |
Thank you Doug, again great work you delivered! Tested the function this morning and all seems to function fine! The only difference is that you changed the |
When exporting phone numbers from active directory user objects into an Excel sheet, the formatting completely disappears. In AD we have phone numbers like '+32 4 4444 444'. But when pass them on to
Export-Excel
it shows us '3244444444' and the plus sign disappears.Example code:
Is there a way to have Excel show the number as a string, like the original? I tried the following without success:
Thank you for your help.
The text was updated successfully, but these errors were encountered: