Skip to content
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

Add option to disable hyperlinking #971

Closed
dbaileyut opened this issue Dec 11, 2020 · 5 comments
Closed

Add option to disable hyperlinking #971

dbaileyut opened this issue Dec 11, 2020 · 5 comments

Comments

@dbaileyut
Copy link
Contributor

Hi,

Using ImportExcel 7.1.1, there doesn't appear to be a way to disable making text a hyperlink if there's letters on either side of a colon. E.g.:

[PSCustomObject]@{Test='abc:123'} | Export-Excel -Path test123.xlsx

Results in this:
image

I have some data that matches this format but I'd like it to be plain text and not a hyperlink. Am I missing something? If not, could you add a parameter or format option to disable hyperlinking?

Thanks!

@dfinke
Copy link
Owner

dfinke commented Dec 11, 2020

No there is no helper functions for the or examples. You'd need to use -PassThru and Set-Format for the range(s) to turn off the underline.

@dbaileyut
Copy link
Contributor Author

That would turn off the underline, but wouldn't it still be a hyperlink?

@dbaileyut
Copy link
Contributor Author

dbaileyut commented Dec 11, 2020

I think what I'm asking for is an option to avoid falling into code paths where "IsWellFormedUriString" evaluates as true like this:

elseif ( [System.Uri]::IsWellFormedUriString($v , [System.UriKind]::Absolute) ) {
if ($v -match "^xl://internal/") {
$referenceAddress = $v -replace "^xl://internal/" , ""
$display = $referenceAddress -replace "!A1$" , ""
$h = New-Object -TypeName OfficeOpenXml.ExcelHyperLink -ArgumentList $referenceAddress , $display
$ws.Cells[$row, $ColumnIndex].HyperLink = $h
}
else {$ws.Cells[$row, $ColumnIndex].HyperLink = $v } #$ws.Cells[$row, $ColumnIndex].Value = $v.AbsoluteUri
$ws.Cells[$row, $ColumnIndex].Style.Font.Color.SetColor([System.Drawing.Color]::Blue)
$ws.Cells[$row, $ColumnIndex].Style.Font.UnderLine = $true
}

@dfinke
Copy link
Owner

dfinke commented Dec 11, 2020

Understood. Sorry, at this point, I don't have the time to build that or add the tests to prove it out.

@dfinke dfinke closed this as completed Dec 11, 2020
@joelwiesmann
Copy link

@dbaileyut I had the same issue today. I solved it with a little workaround:
[PSCustomObject]@{Test='="abc:asd123"'} | Export-Excel -Path test123.xlsx

Might not be the best solution for all use-cases, but for me it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants